diff options
author | NatsuDrag9 | 2018-06-06 16:04:50 +0530 |
---|---|---|
committer | GitHub | 2018-06-06 16:04:50 +0530 |
commit | 8edcd030cb7c3716e4da4a1aceb4f692ffa8bb64 (patch) | |
tree | 411f4316499406d225c50fb64da5bf48240983ab | |
parent | 003741ef327ab000986e6c5a3bc8ff058c171efc (diff) | |
parent | 2307d7aa409430506eeaed03633c8c31dd7f4ac1 (diff) | |
download | LDMicroGtk-8edcd030cb7c3716e4da4a1aceb4f692ffa8bb64.tar.gz LDMicroGtk-8edcd030cb7c3716e4da4a1aceb4f692ffa8bb64.tar.bz2 LDMicroGtk-8edcd030cb7c3716e4da4a1aceb4f692ffa8bb64.zip |
Merge pull request #6 from akshay-c/GUI_port
Gui port pull
66 files changed, 9567 insertions, 9463 deletions
diff --git a/ldmicro/CMakeLists.txt b/ldmicro/CMakeLists.txt index 5486fec..8c568fa 100644 --- a/ldmicro/CMakeLists.txt +++ b/ldmicro/CMakeLists.txt @@ -60,10 +60,39 @@ IF(UNIX) ## Dummy compile and install to test linuxUI ## to compile LDmicro uncomment the below 2 line2 - #add_executable (LDMicro ldmicro.cpp)# miscutil.cpp draw_outputdev.cpp) - # install (TARGETS LDMicro DESTINATION bin) - add_executable (testMain testMain.cpp) - target_link_libraries (testMain LinuxUI) - target_link_libraries (testMain FreezeLD) - install (TARGETS testMain DESTINATION bin) + set (COMPILE_CPP_SOURCES #naminglist.cpp + arduino.cpp + avr.cpp + pic16.cpp + interpreted.cpp + ansic.cpp + compilecommon.cpp + intcode.cpp + lang.cpp + miscutil.cpp + iolist.cpp + #confdialog.cpp + #lutdialog.cpp + #resetdialog.cpp + #simpledialog.cpp + #coildialog.cpp + #contactsdialog.cpp + #commentdialog.cpp + #simulate.cpp + loadsave.cpp + undoredo.cpp + circuit.cpp + draw_outputdev.cpp + #draw.cpp + schematic.cpp + #helpdialog.cpp + maincontrols.cpp + ldmicro.cpp) + + add_executable (LDMicro ${COMPILE_CPP_SOURCES}) + install (TARGETS LDMicro DESTINATION bin) + target_link_libraries (LDMicro LinuxUI) + target_link_libraries (LDMicro FreezeLD) + #add_executable (testMain testMain.cpp) + #install (TARGETS testMain DESTINATION bin) ENDIF(UNIX) diff --git a/ldmicro/RCa02300 b/ldmicro/RCa02300 Binary files differdeleted file mode 100644 index fd5b9e5..0000000 --- a/ldmicro/RCa02300 +++ /dev/null diff --git a/ldmicro/advanceddialog.cpp b/ldmicro/advanceddialog.cpp deleted file mode 100644 index a2b1444..0000000 --- a/ldmicro/advanceddialog.cpp +++ /dev/null @@ -1,1840 +0,0 @@ -#include <windows.h> -#include <commctrl.h> -#include <stdio.h> -#include <stdlib.h> -#include <wincodec.h> -#include <Windowsx.h> -#include <math.h> -// #include "stdafx.h" -// #include <gdiplus.h> - -#include "ldmicro.h" -#include "componentlist.h" -#include "advanceddialog.h" -#include "components\components.h" -#include "naminglist.h" -#include "simulate.h" - - -static HWND HorizScrollBar; -static HWND VertScrollBar; -static HHOOK MouseHookHandle; -static HMENU AdvancedTopMenu; -static int MouseX; -static int MouseY; -static BOOL Clicked = FALSE; -static BOOL DblClicked = FALSE; -static BOOL AdvDialogDone; -static BOOL AdvDialogCancel; -static HMENU AdvancedFileMenu; -static HMENU AdvancedEditMenu; -static HMENU AdvancedSimulateMenu; -static HMENU AdvancedHelpMenu; -static int CyclesPerTimerTick; - - -HWND AdvancedDialog; -HWND AdvancedWorkspace; -HWND ComponentList; -HWND NamingList; -HDC hdc; -HDC HdcMem; -HBITMAP test = NULL; -HANDLE ImageHeap; -BOOL SimulationStarted = FALSE; -HFONT AdvNiceFont; -HFONT AdvFixedFont; -HINSTANCE *ComponentInstance = &Instance; -char MainProgramComponent; - -int AdvWrkspRight; -int AdvWrkspBottom; -int CompListWidth; -int ResizeSwitch; -int NamingListHeight = 100; -UINT TIMERID = 100; -UINT DblClickTimer; -UINT UniquePinId = 0; -UINT MCUCount=0; -UINT NameCount; -BOOL AdvancedWindowOpen = FALSE; -// HBITMAP CreateBitmapMask(HBITMAP hbmColour, COLORREF crTransparent); - -void RefreshDialogScrollbars(void); -void StartAdvSimulationTimer(void); -void CALLBACK CycleAdvTimer(HWND hwnd, UINT msg, UINT_PTR id, DWORD time); - -// PinInfo PinData[MAX_PINS]; -PinMcu McuPin[MAX_MCU_PINS]; -PinName NameId[MAX_PINS]; -PinComponent ComponentPin; - -//----------------------------------------------------------------------------- -// Hook that we install when the user starts dragging the `splitter,' in case -// they drag it out of the narrow area of the drawn splitter bar. Resize -// the listview in response to mouse move, and unhook ourselves when they -// release the mouse button. -//----------------------------------------------------------------------------- -static LRESULT CALLBACK MouseHook(int code, WPARAM wParam, LPARAM lParam) -{ - switch(code) { - case HC_ACTION: { - MSLLHOOKSTRUCT *mhs = (MSLLHOOKSTRUCT *)lParam; - - switch(wParam) { - case WM_MOUSEMOVE: { - /* char vx[3],vy[3]; - _itoa(10,vy,10); - _itoa(ResizeSwitch,vx,10); - MessageBox(AdvancedDialog, - _(vx), _(vy), MB_OK | MB_ICONWARNING);*/ - switch(ResizeSwitch) - { - case 1: - { - int dx = MouseX - mhs->pt.x; - CompListWidth += dx; - if(CompListWidth < 50) CompListWidth = 50; - MouseX = mhs->pt.x; - AdvancedDialogResized(); - break; - } - case 2: - { - int dy = MouseY - mhs->pt.y; - NamingListHeight += dy; - if(NamingListHeight < 50) NamingListHeight = 50; - MouseY = mhs->pt.y; - AdvancedDialogResized(); - } - break; - } - break; - } - - case WM_LBUTTONUP: - ResizeSwitch = 0; - UnhookWindowsHookEx(MouseHookHandle); - break; - } - break; - } - } - return CallNextHookEx(MouseHookHandle, code, wParam, lParam); -} - -static void ProcessAdvancedMenu(int code) -{ - switch(code) { - case MNU_ADV_SIMULATION_MODE: - ToggleSimulationMode(); - ToggleAdvancedSimulationMode(); - break; - - case MNU_ADV_START_SIMULATION: - StartSimulation(); - StartAdvSimulation(); - break; - - case MNU_ADV_STOP_SIMULATION: - StopSimulation(); - StopAdvSimulation(); - break; - - case MNU_ADV_SINGLE_CYCLE: - SimulateOneCycle(TRUE); - SimulateOneAdvCycle(TRUE); - break; - default: - return; - } -} - -void ToggleAdvancedSimulationMode() -{ - - if(InSimulationMode) { - SimulationStarted = TRUE; - EnableMenuItem(AdvancedSimulateMenu, MNU_ADV_START_SIMULATION, MF_ENABLED); - EnableMenuItem(AdvancedSimulateMenu, MNU_ADV_SINGLE_CYCLE, MF_ENABLED); - - EnableMenuItem(AdvancedFileMenu, MNU_ADV_OPEN, MF_GRAYED); - EnableMenuItem(AdvancedFileMenu, MNU_ADV_SAVE, MF_GRAYED); - EnableMenuItem(AdvancedFileMenu, MNU_ADV_SAVE_AS, MF_GRAYED); - EnableMenuItem(AdvancedFileMenu, MNU_ADV_NEW, MF_GRAYED); - - EnableMenuItem(AdvancedTopMenu, 1, MF_GRAYED | MF_BYPOSITION); - /*EnableMenuItem(AdvancedTopMenu, 2, MF_GRAYED | MF_BYPOSITION); - EnableMenuItem(AdvancedTopMenu, 3, MF_GRAYED | MF_BYPOSITION); - EnableMenuItem(AdvancedTopMenu, 5, MF_GRAYED | MF_BYPOSITION);*/ - - CheckMenuItem(AdvancedSimulateMenu, MNU_ADV_SIMULATION_MODE, MF_CHECKED); - - // ClearSimulationData(); - // Recheck InSimulationMode, because there could have been a compile - // error, which would have kicked us out of simulation mode. - /*if(UartFunctionUsed() && InSimulationMode) { - ShowUartSimulationWindow(); - }*/ - } else { - // RealTimeSimulationRunning = FALSE; - //KillTimer(MainWindow, TIMER_SIMULATE); - - EnableMenuItem(AdvancedSimulateMenu, MNU_ADV_START_SIMULATION, MF_GRAYED); - EnableMenuItem(AdvancedSimulateMenu, MNU_ADV_STOP_SIMULATION, MF_GRAYED); - EnableMenuItem(AdvancedSimulateMenu, MNU_ADV_SINGLE_CYCLE, MF_GRAYED); - - EnableMenuItem(AdvancedFileMenu, MNU_ADV_OPEN, MF_ENABLED); - EnableMenuItem(AdvancedFileMenu, MNU_ADV_SAVE, MF_ENABLED); - EnableMenuItem(AdvancedFileMenu, MNU_ADV_SAVE_AS, MF_ENABLED); - EnableMenuItem(AdvancedFileMenu, MNU_ADV_NEW, MF_ENABLED); - - EnableMenuItem(AdvancedTopMenu, 1, MF_ENABLED | MF_BYPOSITION); - /*EnableMenuItem(AdvancedTopMenu, 2, MF_ENABLED | MF_BYPOSITION); - EnableMenuItem(AdvancedTopMenu, 3, MF_ENABLED | MF_BYPOSITION); - EnableMenuItem(AdvancedTopMenu, 5, MF_ENABLED | MF_BYPOSITION);*/ - - CheckMenuItem(AdvancedSimulateMenu, MNU_ADV_SIMULATION_MODE, MF_UNCHECKED); - SimulationStarted = FALSE; - - /*if(UartFunctionUsed()) { - DestroyUartSimulationWindow(); - }*/ - } - - // UpdateMainWindowTitleBar(); - - DrawMenuBar(AdvancedDialog); - InvalidateRect(AdvancedDialog, NULL, FALSE); - // ListView_RedrawItems(, 0, Prog.io.count - 1); -} - -static void CALLBACK DoubleClickProc(HWND hWnd, UINT msg, UINT Id, DWORD sysTime) -{ - KillTimer(AdvancedWorkspace, TIMERID); - if(Clicked) - { - Clicked = FALSE; - } - // MessageBox(AdvancedDialog, "Double click duration", "Mouse Clicked", MB_OK | MB_ICONWARNING); -} - -//----------------------------------------------------------------------------- -// Window procedure for Advanced Simulation Dialog Box -//----------------------------------------------------------------------------- -static LRESULT CALLBACK AdvancedDlgProc(HWND hwnd, UINT msg, WPARAM wParam, - LPARAM lParam) -{ - switch (msg) { - case WM_NOTIFY: { - NMHDR *h = (NMHDR *)lParam; - if(h->hwndFrom == ComponentList) { - ComponentListProc(h); - } - if(h->hwndFrom == NamingList) { - NamingListProc(h); - } - return 0; - break; - } - - case WM_COMMAND: { - HWND h = (HWND)lParam; - if(h == OkButton && wParam == BN_CLICKED) { - AdvDialogDone = TRUE; - } else if(h == CancelButton && wParam == BN_CLICKED) { - AdvDialogDone = TRUE; - AdvDialogCancel = TRUE; - } - ProcessAdvancedMenu(LOWORD(wParam)); - break; - } - case WM_PAINT: { - RECT r; - PAINTSTRUCT ps; - Hdc = BeginPaint(hwnd, &ps); - // Draw the splitter thing to grab to resize componentList - GetClientRect(AdvancedDialog, &r); - r.left = AdvWrkspRight + 1; - r.right = AdvWrkspRight + 2; - FillRect(Hdc, &r, (HBRUSH)GetStockObject(LTGRAY_BRUSH)); - r.left = AdvWrkspRight - 1; - r.right = AdvWrkspRight; - FillRect(Hdc, &r, (HBRUSH)GetStockObject(LTGRAY_BRUSH)); - r.left = AdvWrkspRight; - r.right = AdvWrkspRight + 1; - FillRect(Hdc, &r, (HBRUSH)GetStockObject(WHITE_BRUSH)); - EndPaint(hwnd, &ps); - - // Draw the splitter thing to grab to resize componentList - GetClientRect(AdvancedDialog, &r); - r.top = AdvWrkspBottom + 1; - r.bottom = AdvWrkspBottom + 2; - FillRect(Hdc, &r, (HBRUSH)GetStockObject(LTGRAY_BRUSH)); - r.top = AdvWrkspBottom - 1; - r.bottom = AdvWrkspBottom; - FillRect(Hdc, &r, (HBRUSH)GetStockObject(LTGRAY_BRUSH)); - r.top = AdvWrkspBottom; - r.bottom = AdvWrkspBottom + 1; - FillRect(Hdc, &r, (HBRUSH)GetStockObject(WHITE_BRUSH)); - EndPaint(hwnd, &ps); - return 1; - } - case WM_LBUTTONDOWN: { - // MessageBox(AdvancedDialog, - // _("Mouse Button Clicked"), _("Mouse click"), MB_OK | MB_ICONWARNING); - int x = GET_X_LPARAM(lParam); - int y = GET_Y_LPARAM(lParam); - - POINT pt; - pt.x = x; pt.y = y; - ClientToScreen(AdvancedWorkspace, &pt); - MouseX = pt.x; - MouseY = pt.y; - if((x > (AdvWrkspRight - 9)) && (x < (AdvWrkspRight + 3))) { - - // char vx[3],vy[3]; - // _itoa(y,vy,10); - // _itoa(x,vx,10); - // MessageBox(AdvancedDialog, - // _(vx), _(vy), MB_OK | MB_ICONWARNING); - ResizeSwitch =1; - // InvalidateRect(AdvancedWorkspace, NULL, FALSE); - } - else if((y > (AdvWrkspBottom - 9)) && (y < (AdvWrkspBottom + 3))) - { - ResizeSwitch = 2; - } - if(ResizeSwitch > 0) - { - MouseHookHandle = SetWindowsHookEx(WH_MOUSE_LL, - (HOOKPROC)MouseHook, Instance, 0); - SetFocus(AdvancedWorkspace); - } - break; - } - case WM_MOUSEMOVE: { - int x = GET_X_LPARAM(lParam); - int y = GET_Y_LPARAM(lParam); - if((y >(AdvWrkspBottom - 9)) && (y < (AdvWrkspBottom + 3)) && (x < (AdvWrkspRight + 3))) - { - SetCursor(LoadCursor(NULL, IDC_SIZENS)); - } - else if((x > (AdvWrkspRight - 9)) && (x < (AdvWrkspRight + 3))) - { - SetCursor(LoadCursor(NULL, IDC_SIZEWE)); - } - else - { - SetCursor(LoadCursor(NULL, IDC_ARROW)); - } - break; - } - case WM_SIZE: - AdvancedDialogResized(); - break; - case WM_CLOSE: - case WM_DESTROY: - AdvancedWindowClosing(); - AdvDialogDone = TRUE; - AdvDialogCancel = TRUE; - break; - - default: - return DefWindowProc(hwnd, msg, wParam, lParam); - } - - return 1; -} - -//----------------------------------------------------------------------------- -// Window procedure for Advanced Workspace -// Black workspace area within the Advanced Dialog -//----------------------------------------------------------------------------- -static LRESULT CALLBACK AdvancedWrkspProc(HWND hwnd, UINT msg, WPARAM wParam, - LPARAM lParam) -{ - switch (msg) { - case WM_NOTIFY: { - break; - } - - case WM_COMMAND: { - HWND h = (HWND)lParam; - if(h == OkButton && wParam == BN_CLICKED) { - AdvDialogDone = TRUE; - } else if(h == CancelButton && wParam == BN_CLICKED) { - AdvDialogDone = TRUE; - AdvDialogCancel = TRUE; - } - break; - } - case WM_CREATE:{ - // test=LoadBitmap(GetModuleHandle(NULL),"relay_nc.bmp"); - /*test = (HBITMAP) LoadBitmap (Instance, MAKEINTRESOURCE(RELAY_NC));//,IMAGE_BITMAP, - // 0,0, LR_LOADTRANSPARENT); - if(test ==NULL){ - MessageBox(hwnd, "Could not load Bitmap!", "Error", MB_OK | MB_ICONEXCLAMATION); - }*/ - /*testmask = CreateBitmapMask(test, RGB(255, 255, 255)); - if(testmask ==NULL){ - MessageBox(hwnd, "Could not create mask!", "Error", MB_OK | MB_ICONEXCLAMATION); - }*/ - } - break; - case WM_PAINT:{ - PAINTSTRUCT ps; - int i; - hdc = BeginPaint(hwnd, &ps); - for(i=0; i < ImagesDrawn; i++) - { - ImageList_Draw(ImageStack[i].Image->Images, 0, hdc, - ImageStack[i].x, ImageStack[i].y, ILD_TRANSPARENT); - } - // if(ComponentDiagrams == NULL){ - // InitializeImageList(); - // } - // InitializeComponentImage(0); - // DeleteDC(HdcMem); - EndPaint(hwnd, &ps); - } - break; - case WM_LBUTTONDOWN:{ - // left button down - int x = GET_X_LPARAM(lParam); - int y = GET_Y_LPARAM(lParam); - if(!SimulationStarted) - { - // char vx[3],vy[3]; - // _itoa(y,vy,10); - // _itoa(x,vx,10); - // MessageBox(AdvancedDialog, _(vx), _(vy), MB_OK | MB_ICONWARNING); - BeginComponentDrag(x, y); - } - else{ - // Send message to respective component - - } - ProcessEvent(x, y, EVENT_MOUSE_DOWN); - } - break; - case WM_LBUTTONUP:{ - int x = GET_X_LPARAM(lParam); - int y = GET_Y_LPARAM(lParam); - if(!SimulationStarted){ - EndComponentDrag(x, y); - } - else{ - // Send message to respective component - ProcessEvent(x, y, EVENT_MOUSE_UP); - } - // if((DragX < (x + 3)) && (DragX > (x-3)) && (DragY < (y + 3)) && (DragY > (y-3))) - { - /*MessageBox(NULL, - ("Reached"), ("Info"), MB_OK | MB_ICONWARNING);*/ - ProcessEvent(x, y, EVENT_MOUSE_CLICK); - // char vx[3],vy[3]; - // _itoa(y,vy,10); - // _itoa(x,vx,10); - // MessageBox(AdvancedDialog, _(vx), _(vy), MB_OK | MB_ICONWARNING); - // MessageBox(AdvancedDialog, "Mouse Clicked", "Mouse Clicked", MB_OK | MB_ICONWARNING); - } - } - break; - // case WM_LBUTTONDBLCLK: - // { - // int x = GET_X_LPARAM(lParam); - // int y = GET_Y_LPARAM(lParam); - // // MessageBox(AdvancedDialog, "Mouse DoubleClicked", "Mouse Double Clicked", MB_OK | MB_ICONWARNING); - // if(SimulationStarted){ - // // Send message to respective component - // } - // else - // { - // } - // ProcessEvent(x, y, EVENT_MOUSE_DBLCLICK); - // } - // break; - case WM_RBUTTONUP: - { - int x = GET_X_LPARAM(lParam); - int y = GET_Y_LPARAM(lParam); - if(!SimulationStarted) - { - // Get Pin Parameters Here - } - ProcessEvent(x,y,EVENT_MOUSE_RCLICK); - } - break; - case WM_MOUSEMOVE:{ - int x = GET_X_LPARAM(lParam); - int y = GET_Y_LPARAM(lParam); - ComponentDrag(x, y); - } - break; - // case WM_SIZE: - // AdvancedDialogResized(); - // break; - case WM_CLOSE: - case WM_DESTROY:{ - AdvDialogDone = TRUE; - AdvDialogCancel = TRUE; - // HeapDestroy(ImageHeap); - } - break; - - default: - return DefWindowProc(hwnd, msg, wParam, lParam); - } - - return 1; -} -/*HBITMAP CreateBitmapMask(HBITMAP hbmColour, COLORREF crTransparent) -{ - HDC HdcMem, HdcMem2; - HBITMAP HbmMask; - BITMAP bm; - // Create monochrome (1 bit) mask bitmap. - GetObject(hbmColour, sizeof(BITMAP), &bm); - HbmMask = CreateBitmap(bm.bmWidth, bm.bmHeight, 1, 1, NULL); - // Get some HDCs that are compatible with the display driver - HdcMem = CreateCompatibleDC(0); - HdcMem2 = CreateCompatibleDC(0); - SelectObject(HdcMem, hbmColour); - SelectObject(HdcMem2, HbmMask); - // Set the background colour of the colour image to the colour - // you want to be transparent. - SetBkColor(HdcMem, crTransparent); - - BitBlt(HdcMem2, 0, 0, bm.bmWidth, bm.bmHeight, HdcMem, 0, 0, SRCCOPY); - BitBlt(HdcMem, 0, 0, bm.bmWidth, bm.bmHeight, HdcMem2, 0, 0, SRCINVERT); - DeleteDC(HdcMem); - DeleteDC(HdcMem2); - return HbmMask; -}*/ - -//----------------------------------------------------------------------------- -//Create dialog box classes specifically for Advanced Simulation -//----------------------------------------------------------------------------- - -void MakeAdvancedDialogClass(void) -{ - WNDCLASSEX wc; - memset(&wc, 0, sizeof(wc)); - wc.cbSize = sizeof(wc); - - wc.style = CS_BYTEALIGNCLIENT | CS_BYTEALIGNWINDOW | CS_OWNDC | - CS_DBLCLKS; - wc.lpfnWndProc = (WNDPROC)AdvancedDlgProc; - wc.hInstance = Instance; - wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); - wc.lpszClassName = "AdvancedDialog"; - wc.lpszMenuName = NULL; - wc.hCursor = LoadCursor(NULL, IDC_SIZEWE); - wc.hIcon = (HICON)LoadImage(Instance, MAKEINTRESOURCE(4000), - IMAGE_ICON, 32, 32, 0); - wc.hIconSm = (HICON)LoadImage(Instance, MAKEINTRESOURCE(4000), - IMAGE_ICON, 16, 16, 0); - - RegisterClassEx(&wc); - - AdvNiceFont = CreateFont(16, 0, 0, 0, FW_REGULAR, FALSE, FALSE, FALSE, - ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, - FF_DONTCARE, "Tahoma"); - if(!AdvNiceFont) - AdvNiceFont = (HFONT)GetStockObject(SYSTEM_FONT); - - AdvFixedFont = CreateFont(14, 0, 0, 0, FW_REGULAR, FALSE, FALSE, FALSE, - ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, - FF_DONTCARE, "Lucida Console"); - if(!AdvFixedFont) - AdvFixedFont = (HFONT)GetStockObject(SYSTEM_FONT); -} - -void MakeAdvancedWorkspaceClass(void) -{ - WNDCLASSEX wc; - memset(&wc, 0, sizeof(wc)); - wc.cbSize = sizeof(wc); - - wc.style = CS_BYTEALIGNWINDOW | CS_BYTEALIGNWINDOW | CS_OWNDC; - wc.lpfnWndProc = (WNDPROC)AdvancedWrkspProc; - wc.hInstance = Instance; - wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); - wc.lpszClassName = "AdvancedWorkspace"; - wc.lpszMenuName = NULL; - RegisterClassEx(&wc); - -} -void MakeComponentListClass(void) -{ - WNDCLASSEX wc; - memset(&wc, 0, sizeof(wc)); - wc.cbSize = sizeof(wc); - - wc.style = CS_BYTEALIGNWINDOW | CS_BYTEALIGNWINDOW | CS_OWNDC | - CS_DBLCLKS; - wc.lpfnWndProc = (WNDPROC)AdvancedWrkspProc; - wc.hInstance = Instance; - // wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); - wc.lpszClassName = "ComponentList"; - // wc.lpszMenuName = NULL; - RegisterClassEx(&wc); -} - -void MakeNamingListClass(void) -{ - WNDCLASSEX wc; - memset(&wc, 0, sizeof(wc)); - wc.cbSize = sizeof(wc); - - wc.style = CS_BYTEALIGNWINDOW | CS_BYTEALIGNWINDOW | CS_OWNDC | - CS_DBLCLKS; - wc.lpfnWndProc = (WNDPROC)AdvancedDlgProc; - wc.hInstance = Instance; - // wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); - wc.lpszClassName = "NamingList"; - // wc.lpszMenuName = NULL; - RegisterClassEx(&wc); -} - -void ShowAdvancedDialog() -{ - // int itmcount = Prog.io.count; - // char vx[3],vy[3]; - // _itoa(10,vy,10); - // _itoa(itmcount,vx,10); - // MessageBox(MainWindow, - // _(vx), _(vy), MB_OK | MB_ICONWARNING); - if(AdvancedWindowOpen) - { - return; - } - ComponentPin.Count = 0; - ImageHeap = HeapCreate(0, 1024*64, 0); - MakeAdvancedWindowMenus(); - AdvancedDialog = CreateWindowClient(WS_EX_CONTROLPARENT, "AdvancedDialog", - _("Advanced Simulation Mode"), WS_OVERLAPPED | WS_SYSMENU - | WS_THICKFRAME | WS_CLIPCHILDREN | WS_SIZEBOX, - 10 , 10 , 800 , 600 , NULL , AdvancedTopMenu , Instance , NULL ); - InitComponents(); - RECT r; - CompListWidth = 160; - MakeAdvancedDialogControls(); - // AdvancedDialogResized(); - //RefreshDialogScrollbars(); - GetClientRect(AdvancedDialog , &r ); - - // EnableWindow(MainWindow, FALSE); - ShowWindow(AdvancedDialog, SW_SHOW); - AdvancedWindowOpen = TRUE; - ToggleAdvancedSimulationMode(); - - MSG msg; - DWORD ret; - AdvDialogDone = FALSE; - AdvDialogCancel = FALSE; - while((ret = GetMessage(&msg, NULL, 0, 0)) && !AdvDialogDone) { - // if(msg.message == WM_KEYDOWN) { - // if(msg.wParam == VK_RETURN) { - // AdvDialogDone = TRUE; - // break; - // } else if(msg.wParam == VK_ESCAPE) { - // AdvDialogDone = TRUE; - // AdvDialogCancel = TRUE; - // break; - // } - // } - - if(IsDialogMessage(AdvancedDialog , &msg)) continue; - TranslateMessage(&msg); - DispatchMessage(&msg); - } - - // EnableWindow(MainWindow, TRUE); - DestroyWindow(AdvancedDialog); - AdvancedWindowOpen = FALSE; - return; -} - -void MakeAdvancedDialogControls(void) -{ - LVCOLUMN lvc; - lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM; - lvc.fmt = LVCFMT_LEFT; -#define LV_ADD_COLUMN(hWnd, i, w, s) do { \ - lvc.iSubItem = i; \ - lvc.pszText = s; \ - lvc.iOrder = 0; \ - lvc.cx = w; \ - ListView_InsertColumn(hWnd, i, &lvc); \ - } while(0) - - AdvancedWorkspace = CreateWindowEx(WS_EX_CLIENTEDGE, "AdvancedWorkspace", "", - WS_CHILD | WS_CLIPSIBLINGS | WS_TABSTOP, - 0 , 0 , 640 , 600 , AdvancedDialog , NULL , Instance , NULL ); - - ComponentList = CreateWindowEx(WS_EX_CLIENTEDGE, WC_LISTVIEW, "ComponentList", WS_CHILD | - LVS_REPORT | LVS_NOSORTHEADER | LVS_SORTASCENDING | LVS_SHOWSELALWAYS | WS_TABSTOP | - LVS_SINGLESEL | WS_CLIPSIBLINGS, - 12, 25, 300, 300, AdvancedDialog, NULL, Instance, NULL); - ListView_SetExtendedListViewStyle(ComponentList, LVS_EX_FULLROWSELECT); - LV_ADD_COLUMN(ComponentList, 0, 150, _("Components")); - ComponentListInitiate(); - - NamingList = CreateWindowEx(WS_EX_CLIENTEDGE, WC_LISTVIEW, "NamingList", WS_CHILD | - LVS_REPORT | LVS_NOSORTHEADER | LVS_SORTASCENDING | LVS_SHOWSELALWAYS | WS_TABSTOP | - LVS_SINGLESEL | WS_CLIPSIBLINGS, 312, 325, 300, 300, AdvancedDialog, NULL, Instance, NULL); - LV_ADD_COLUMN(NamingList, 0, 250, _("Name")); - LV_ADD_COLUMN(NamingList, 1, 100, _("State/Volt")); - LV_ADD_COLUMN(NamingList, 2, 100, _("Pin on Processor")); - LV_ADD_COLUMN(NamingList, 3, 100, _("MCU Port")); - PopulateNamingList(); - RefreshNamingList(); - // HorizScrollBar = CreateWindowEx(0, WC_SCROLLBAR, "", WS_CHILD | - // SBS_HORZ | SBS_BOTTOMALIGN | WS_VISIBLE | WS_CLIPSIBLINGS, - // 100, 100, 100, 100, AdvancedDialog, NULL, Instance, NULL); - // VertScrollBar = CreateWindowEx(0, WC_SCROLLBAR, "", WS_CHILD | - // SBS_VERT | SBS_LEFTALIGN | WS_VISIBLE | WS_CLIPSIBLINGS, - // 200, 100, 100, 100, AdvancedDialog, NULL, Instance, NULL); - // RECT scroll; - // GetWindowRect(HorizScrollBar, &scroll); - // ScrollHeight = scroll.bottom - scroll.top; - // GetWindowRect(VertScrollBar, &scroll); - // ScrollWidth = scroll.right - scroll.left; - /*ComponentList = CreateWindowEx(WS_EX_CLIENTEDGE, TEXT("listbox"), "Test", WS_CHILD - | WS_VISIBLE | WS_VSCROLL | ES_AUTOVSCROLL | WS_CLIPSIBLINGS | WS_TABSTOP, - 240, 40, 150, 20, AdvancedDialog, NULL, Instance, NULL); - SendMessage(ComponentList, LB_ADDSTRING, 0, (LPARAM)"name"); - SendMessage(ComponentList, LB_ADDSTRING, 0, (LPARAM)"extension"); - SendMessage(ComponentList, LB_ADDSTRING, 0, (LPARAM)"date"); - SendMessage(ComponentList, LB_ADDSTRING, 0, (LPARAM)"size");*/ - ShowWindow(AdvancedWorkspace, SW_SHOW); - ShowWindow(ComponentList, SW_SHOW); - ShowWindow(NamingList, SW_SHOW); -} - -void AdvancedDialogResized(void) -{ - RECT AdvDial; - GetClientRect(AdvancedDialog, &AdvDial); - - if(CompListWidth < 30) { - CompListWidth = 30; - } - if(CompListWidth > AdvDial.right - 250){ - CompListWidth = AdvDial.right - 250; - } - if(NamingListHeight < 30) { - NamingListHeight = 30; - } - if(NamingListHeight > AdvDial.bottom - 250){ - NamingListHeight = AdvDial.bottom - 250; - } - AdvWrkspRight = AdvDial.right - CompListWidth; - AdvWrkspBottom = AdvDial.bottom - NamingListHeight; - MoveWindow(AdvancedWorkspace, 0, 0, - AdvWrkspRight - 1, AdvWrkspBottom - 1, TRUE); - MoveWindow(ComponentList, AdvWrkspRight + 2, 0, - CompListWidth, AdvDial.bottom, TRUE); - MoveWindow(NamingList, 0, AdvWrkspBottom + 2, - AdvWrkspRight - 1, AdvDial.bottom - AdvWrkspBottom - 2, TRUE); - ListView_SetColumnWidth(ComponentList, 0, AdvDial.right - AdvWrkspRight - 5); -} - -void MakeAdvancedWindowMenus(void) -{ - AdvancedFileMenu = CreatePopupMenu(); - AppendMenu(AdvancedFileMenu, MF_STRING, MNU_ADV_NEW, _("&New\tCtrl+N")); - AppendMenu(AdvancedFileMenu, MF_STRING, MNU_ADV_OPEN, _("&Open...\tCtrl+O")); - AppendMenu(AdvancedFileMenu, MF_STRING, MNU_ADV_SAVE, _("&Save\tCtrl+S")); - AppendMenu(AdvancedFileMenu, MF_STRING, MNU_ADV_SAVE_AS, _("Save &As...")); - AppendMenu(AdvancedFileMenu, MF_SEPARATOR, 0, ""); - AppendMenu(AdvancedFileMenu, MF_STRING, MNU_EXIT, _("E&xit")); - - AdvancedEditMenu = CreatePopupMenu(); - AppendMenu(AdvancedEditMenu, MF_STRING, MNU_ADV_UNDO, _("&Undo\tCtrl+Z")); - AppendMenu(AdvancedEditMenu, MF_STRING, MNU_ADV_REDO, _("&Redo\tCtrl+Y")); - AppendMenu(AdvancedEditMenu, MF_SEPARATOR, 0, NULL); - AppendMenu(AdvancedEditMenu, MF_STRING, MNU_ADV_CUT, _("Cu&t\tCtrl+X")); - AppendMenu(AdvancedEditMenu, MF_STRING, MNU_ADV_COPY, _("&Copy\tCtrl+C")); - AppendMenu(AdvancedEditMenu, MF_STRING, MNU_ADV_PASTE, _("&Paste\tCtrl+V")); - AppendMenu(AdvancedEditMenu, MF_SEPARATOR, 0, NULL); - AppendMenu(AdvancedEditMenu, MF_STRING, MNU_ADV_DEL, _("De&lete\tCtrl+Y")); - - AdvancedSimulateMenu = CreatePopupMenu(); - AppendMenu(AdvancedSimulateMenu, MF_STRING, MNU_ADV_SIMULATION_MODE, - _("Si&mulation Mode\tCtrl+M")); - AppendMenu(AdvancedSimulateMenu, MF_STRING | MF_GRAYED, - MNU_ADV_START_SIMULATION, _("Start &Real-Time Simulation\tCtrl+R")); - AppendMenu(AdvancedSimulateMenu, MF_STRING | MF_GRAYED, - MNU_ADV_STOP_SIMULATION, _("&Halt Simulation\tCtrl+H")); - AppendMenu(AdvancedSimulateMenu, MF_STRING | MF_GRAYED, - MNU_ADV_SINGLE_CYCLE, _("Single &Cycle\tSpace")); - - AdvancedHelpMenu = CreatePopupMenu(); - AppendMenu(AdvancedHelpMenu, MF_STRING, MNU_ADV_MANUAL, _("&Manual...\tF1")); - AppendMenu(AdvancedHelpMenu, MF_STRING, MNU_ADV_ABOUT, _("&About...")); - - AdvancedTopMenu = CreateMenu(); - AppendMenu(AdvancedTopMenu, MF_STRING | MF_POPUP, - (UINT_PTR)AdvancedFileMenu, _("&File")); - AppendMenu(AdvancedTopMenu, MF_STRING | MF_POPUP, - (UINT_PTR)AdvancedEditMenu, _("&Edit")); - AppendMenu(AdvancedTopMenu, MF_STRING | MF_POPUP, - (UINT_PTR)AdvancedSimulateMenu, _("Si&mulate")); - AppendMenu(AdvancedTopMenu, MF_STRING | MF_POPUP, - (UINT_PTR)AdvancedHelpMenu, _("&Help")); - -} - -void ProcessEvent(int x, int y, int Event) -{ - int i = 0; - switch(Event) - { - case EVENT_MOUSE_CLICK: - { - if(Clicked) - { - KillTimer(AdvancedWorkspace, TIMERID); - Event = EVENT_MOUSE_DBLCLICK; - Clicked = FALSE; - }else - { - Clicked = TRUE; - DblClickTimer = SetTimer(AdvancedWorkspace, TIMERID, - GetDoubleClickTime(), DoubleClickProc); - } - break; - } - } - - for(i = 0; i < ImagesDrawn; i++) - { - if((((ImageStack[i].x + COMPONENT_WIDTH) > x) && - (ImageStack[i].x < x) && - (ImageStack[i].y < y) && - ((ImageStack[i].y + COMPONENT_HEIGHT) > y))) - { - /*char Debug[256]; - sprintf_s(Debug, "Editing Component Address: %p\n",ImageStack[i].Properties); - OutputDebugString(Debug);*/ - NotifyComponent(ImageStack[i].Properties, ImageStack[i].PinName, - ImageStack[i].Image->ComponentId, Event, SimulationStarted, - &AdvancedDialog, ImageStack[i].Index, ImageStack[i].Id, - &ImageStack[i].Image->Images); //Replace Image in Imagelist here - } - } -} - -void* AllocImageHeap(size_t n) -{ - void *p = HeapAlloc(ImageHeap, HEAP_ZERO_MEMORY, n); - return p; -} - -void* ReallocImageHeap(LPVOID lpMem, size_t n) -{ - // char Debug[256]; - void *p = HeapReAlloc(ImageHeap, HEAP_ZERO_MEMORY, - lpMem, n); - if(p == NULL) - { - /*sprintf_s(Debug, "Cannot Reallocate Memory\n"); - OutputDebugString(Debug);*/ - return lpMem; - } - return p; -} - -void FreeImageHeap(void *p) -{ - HeapFree(ImageHeap, 0, p); -} - -void SetMcu(int PinId, int Type) -{ - UINT i; - for(i=0; i<MCUCount; i++) - { - if(McuPin[i].PinId == PinId) - { - McuPin[i].type = Type; - McuPin[i].InternalPullup = TRUE; - return; - } - } - McuPin[MCUCount].type = Type; - McuPin[MCUCount].InternalPullup = TRUE; - McuPin[MCUCount++].PinId = PinId; - /*char vx[3],vy[3]; - _itoa(MCUCount,vy,10); - _itoa(McuPin[MCUCount].type,vx,10); - MessageBox(NULL, - _("SetMcu"), _(vx), MB_OK | MB_ICONWARNING);*/ -} - -void ToggleInternalPullup(int PinId) -{ - for(UINT i=0;i<MCUCount;i++) - { - if(McuPin[i].PinId == PinId) - { - McuPin[i].InternalPullup = !(McuPin[i].InternalPullup); - } - } -} - -int RegisterPinName(LPCTSTR Name) -{ - UINT i; - if(Name[0] == 0) - { - return 0; - } - for(i=0; i<NameCount; i++) - { - if((strcmp(NameId[i].Name, Name)) == 0) - { - return NameId[i].PinId; - } - } - // NameId[NameCount].PinData->ImageId = (void**)AllocImageHeap(sizeof(void*)); - NameId[NameCount].PinData.ImageId = (void**)AllocImageHeap(sizeof(void*)); - NameId[NameCount].PinData.ImageType = (int*)AllocImageHeap(sizeof(int)); - NameId[NameCount].PinData.Index = (int*)AllocImageHeap(sizeof(int)); - // NameId[NameCount].PinData = &PinData[NameCount]; - NameId[NameCount].PinData.LinkCount = 0; - //SetMcu(NameCount, ImageId); - NameId[NameCount].PinId = ++UniquePinId; - - if (sizeof(TCHAR) == sizeof(char)) // String is non-unicode - strcpy(NameId[NameCount].Name, (char*)(Name)); - else // String is unicode - wcstombs(NameId[NameCount].Name, (wchar_t*)Name, MAX_NAME_LENGTH); - // MessageBox(AdvancedDialog, (LPCTSTR)NameId[NameCount].Name, "Registered", MB_OK | MB_ICONWARNING); - - /*char vx[3],vy[3]; - _itoa(10,vy,10); - _itoa(NameId[NameCount].PinId,vx,10); - MessageBox(AdvancedDialog, - _(vx), Name, MB_OK | MB_ICONWARNING);*/ - NameCount++; - RefreshNamingList(); - return NameId[i].PinId; -} -int DeletePinImage(LPCTSTR Name, void* ImageId, int Index) -{ - UINT i; - int Count, j, index; - int PinId = -1; - void* Value; - - if(Name[0] == 0) - { - return PinId; - } - for(i=0; i<NameCount; i++) - { - if((strcmp(NameId[i].Name, Name)) == 0) - { - PinId = NameId[i].PinId; - Count = NameId[i].PinData.LinkCount; - if(Count == 0) - { - DeletePinName(i); - return PinId; - } - /*char vx[3],vy[3]; - // _itoa(Index,vy,10); - _itoa(Count,vx,10); - MessageBox(AdvancedDialog, - _(vx), "Deleting", MB_OK | MB_ICONWARNING);*/ - for(j =0; j < Count; j++) - { - Value =(void*) NameId[i].PinData.ImageId[j]; - index = NameId[i].PinData.Index[j]; - /*char vx[20],vy[3]; - // _itoa(Index,vy,10); - _itoa((int)Value,vx,10); - MessageBox(AdvancedDialog, - _(vx), "Deleting", MB_OK | MB_ICONWARNING);*/ - if((ImageId == Value) /*&& (Index == index)*/) - { - // MessageBox(NULL,"Value found","Info",MB_OK|MB_ICONWARNING); - if(index==Index) - { - NameId[i].PinData.ImageId[j] = - NameId[i].PinData.ImageId[--Count]; - NameId[i].PinData.ImageType[j] = - NameId[i].PinData.ImageType[Count]; - NameId[i].PinData.Index[j] = - NameId[i].PinData.Index[Count]; - NameId[i].PinData.LinkCount = Count; - NameId[i].PinData.ImageId = - (void**)ReallocImageHeap( - (void**)NameId[i].PinData.ImageId, - (Count * sizeof(void*))); - NameId[i].PinData.ImageType = - (int*)ReallocImageHeap(NameId[i].PinData.ImageType, - (Count * sizeof(int))); - NameId[i].PinData.Index = - (int*)ReallocImageHeap(NameId[i].PinData.Index, - (Count * sizeof(int))); - /*char Debug[256]; - sprintf_s(Debug, "Deleting Index[%d]", j); - OutputDebugString(Debug);*/ - /*char vx[3],vy[3]; - // _itoa(Index,vy,10); - _itoa(Count,vx,10); - MessageBox(AdvancedDialog, - _(vx), "Deleting", MB_OK | MB_ICONWARNING);*/ - /*char vx[3],vy[3]; - _itoa(Index,vy,10); - _itoa(Count,vx,10); - MessageBox(AdvancedDialog, - _(vx), _(vy), MB_OK | MB_ICONWARNING);*/ - if(Count == 0) - { - DeletePinName(i); - } - return PinId; - } - } - } - } - } - return -1; -} - -int DeleteComponentPin(int PinId, void* ComponentAddress) -{ - PinComponent* temp = (PinComponent*)ComponentPin.Next; - PinComponent* Prev = &ComponentPin; - if(ComponentPin.PinId == NULL) - { - return -1; - } - else if(ComponentPin.PinId == PinId) - { - for(int i=0;i<ComponentPin.Count;i++) - { - if(ComponentPin.ComponentAddress[i] == ComponentAddress) - { - ComponentPin.ComponentAddress[i] = - ComponentPin.ComponentAddress[(--ComponentPin.Count)]; - ReallocImageHeap(ComponentPin.ComponentAddress, - sizeof(void*)*ComponentPin.Count); - return PinId; - } - } - if(ComponentPin.Count == 0) - { - if(ComponentPin.Next == NULL) - { - ComponentPin.PinId = NULL; - return PinId; - } - else - { - ComponentPin = *temp; - FreeImageHeap((void*)temp); - } - return PinId; - } - } - else - { - while(temp != NULL) - { - if(temp->PinId == PinId) - { - for(int i=0; i<temp->Count; i++) - { - if(temp->ComponentAddress[i] == ComponentAddress) - { - if(temp->Count == 1) - { - Prev->Next = temp->Next; - FreeImageHeap((void*)temp); - } - else - { - temp->ComponentAddress[i] = - temp->ComponentAddress[ - (--temp->Count)]; - ReallocImageHeap(temp->ComponentAddress, - sizeof(void*) * (temp->Count)); - return PinId; - } - } - Prev = temp; - temp = (PinComponent*)temp->Next; - } - } - } - } - return -1; -} -int AddComponentPin(int PinId, void* ComponentAddress) -{ - PinComponent* temp = (PinComponent*)ComponentPin.Next; - if(ComponentPin.PinId == NULL) - { - ComponentPin.PinId = PinId; - ComponentPin.Count = 1; - ComponentPin.ComponentAddress = (void**)AllocImageHeap(sizeof(void*)); - ComponentPin.ComponentAddress[0] = ComponentAddress; - return PinId; - } - else if(ComponentPin.PinId == PinId) - { - ComponentPin.ComponentAddress = (void**)ReallocImageHeap( - (void*)ComponentPin.ComponentAddress, - (sizeof(void*)) * (++ComponentPin.Count)); - ComponentPin.ComponentAddress[(ComponentPin.Count-1)] =ComponentAddress; - return PinId; - } - else - { - PinComponent* Prev = &ComponentPin; - while(temp != NULL) - { - if(temp->PinId == PinId) - { - temp->ComponentAddress = (void**)ReallocImageHeap( - (void*)ComponentPin.ComponentAddress, - (sizeof(void*) * (++ComponentPin.Count))); - temp->ComponentAddress[ - (ComponentPin.Count-1)] = ComponentAddress; - return PinId; - } - Prev = temp; - temp = (PinComponent*) temp->Next; - } - temp = (PinComponent*) AllocImageHeap(sizeof(PinComponent)); - temp->PinId =PinId; - temp->ComponentAddress = (void**)AllocImageHeap(sizeof(void*)); - temp->Count = 1; - temp->ComponentAddress[0] = ComponentAddress; - Prev->Next = (void*)temp; - return PinId; - } - return -1; -} - -int SetPinImage(int PinId, void* ImageId, int ImageType, int Index) -{ - UINT i,j, Count; - void* Value; - int index; - for(i=0; i<NameCount; i++) - { - if(NameId[i].PinId == PinId) - { - Count = NameId[i].PinData.LinkCount; - for(j =0; j<Count; j++) - { - Value =(void*) NameId[i].PinData.ImageId[j]; - index = NameId[i].PinData.Index[j]; - if((ImageId == Value) && (index == Index)) - { - /*char Debug[256]; - sprintf_s(Debug, "Already Exists\n"); - OutputDebugString(Debug);*/ - return NameId[i].PinId; - } - } - NameId[i].PinData.LinkCount = ++Count; - NameId[i].PinData.ImageId = - (void**)ReallocImageHeap((void**)NameId[i].PinData.ImageId, - (Count) * sizeof(void*)); - NameId[i].PinData.ImageType = - (int*)ReallocImageHeap(NameId[i].PinData.ImageType, - (Count) * sizeof(int)); - NameId[i].PinData.Index = - (int*)ReallocImageHeap(NameId[i].PinData.Index, - (Count) * sizeof(int)); - NameId[i].PinData.ImageId[Count-1] = ImageId; - NameId[i].PinData.ImageType[Count-1] = ImageType; - NameId[i].PinData.Index[Count-1] = Index; - /*char Debug[256]; - sprintf_s(Debug, "Adding ImageId[%d]: %p \t Previous: %p\n", - Count-1,NameId[i].PinData.ImageId[Count-1],NameId[i].PinData.ImageId[0]); - OutputDebugString(Debug);*/ - /*for(j =0; j<Count; j++) - { - char vx[20],vy[3]; - // _itoa(Index,vy,10); - _itoa((int)NameId[i].PinData.ImageId[j],vx,10); - MessageBox(AdvancedDialog, - _(vx), "Count", MB_OK | MB_ICONWARNING); - }*/ - /*char vx[20],vy[3]; - // _itoa(Index,vy,10); - _itoa((int)ImageId,vx,10); - MessageBox(AdvancedDialog, - _(vx), "Count", MB_OK | MB_ICONWARNING);*/ - return NameId[i].PinId; - } - } - return -1; -} - -int DeletePinName(UINT Index) -{ - UINT i; - UINT PinId = NameId[Index].PinId; - for(i=0;i<MCUCount;i++) - { - if(PinId == McuPin[i].PinId) - { - return 0; - } - } - FreeImageHeap(NameId[Index].PinData.ImageId); - FreeImageHeap(NameId[Index].PinData.ImageType); - FreeImageHeap(NameId[Index].PinData.Index); - NameId[Index] = NameId[--NameCount]; - RefreshNamingList(); - return 1; -} - -void AdvancedWindowClosing() -{ - FlushPinNames(); -} - -int FlushPinNames() -{ - UINT i; - int Count = 0; - for(i=0; i<NameCount && NameCount>0; i++) - { - if(NameId[i].PinData.LinkCount<=0) - { - // MessageBox(NULL, (LPCTSTR)NameId[i].Name,"Deleted", MB_OK | MB_ICONWARNING); - NameId[i--] = NameId[--NameCount]; - Count++; - } - } - RefreshNamingList(); - /*char vx[3],vy[3]; - _itoa(10,vy,10); - _itoa(NameCount,vx,10); - MessageBox(NULL, - _(vx), _(vy), MB_OK | MB_ICONWARNING);*/ - MCUCount =0; - return Count; -} - -void StartAdvSimulation() -{ - // RealTimeSimulationRunning = TRUE; - EnableMenuItem(AdvancedSimulateMenu, MNU_ADV_START_SIMULATION, MF_GRAYED); - EnableMenuItem(AdvancedSimulateMenu, MNU_ADV_STOP_SIMULATION, MF_ENABLED); - StartAdvSimulationTimer(); - - // UpdateMainWindowTitleBar(); -} - -//----------------------------------------------------------------------------- -// Stop real-time simulation. Have to update the controls grayed status -// to reflect this. -//----------------------------------------------------------------------------- -void StopAdvSimulation() -{ - // RealTimeSimulationRunning = FALSE; - EnableMenuItem(AdvancedSimulateMenu, MNU_ADV_START_SIMULATION, MF_ENABLED); - EnableMenuItem(AdvancedSimulateMenu, MNU_ADV_STOP_SIMULATION, MF_GRAYED); - KillTimer(MainWindow, TIMER_SIMULATE); - // UpdateMainWindowTitleBar(); -} - -void SimulateOneAdvCycle(BOOL ForceRefresh) -{ - static BOOL Simulating = FALSE; - if(Simulating) return; - Simulating = TRUE; - /*Code here*/ - Simulating = FALSE; -} - -void StartAdvSimulationTimer() -{ - int p = Prog.cycleTime/1000; - if(p < 5) - { - SetTimer(AdvancedDialog, TIMER_ADV_SIMULATE, 10, CycleAdvTimer); - CyclesPerTimerTick = 10000 / Prog.cycleTime; - }else - { - SetTimer(AdvancedDialog, TIMER_ADV_SIMULATE, p, CycleAdvTimer); - CyclesPerTimerTick = 1; - } -} - -void CALLBACK CycleAdvTimer(HWND hwnd, UINT msg, UINT_PTR id, DWORD time) -{ - int i; - for(i = 0; i < CyclesPerTimerTick; i++) - { - SimulateOneAdvCycle(FALSE); - } -} - -// void CreateVoltRequest(int Index, double VoltReq) -// { -// void* Value; -// UINT Count,j; -// Count = NameId[Index].PinData.LinkCount; -// /*char vx[4],vy[4]; -// _itoa(NameId[i].PinData.Volt,vy,10); -// _itoa(VoltReq,vx,10); -// MessageBox(NULL, -// (vy), (vx), MB_OK | MB_ICONWARNING);*/ -// if(Count>0) -// { -// // MessageBox(NULL,"reached", "info", MB_OK | MB_ICONEXCLAMATION); -// for(j =0; j < Count; j++) -// { -// Value = (void*) NameId[Index].PinData.ImageId[j]; -// for(int k =0; k<ImagesDrawn; k++) -// { -// if(ImageStack[k].Properties == Value) -// { -// NameId[Index].PinData.Volt = VoltSet(Value, SimulationStarted, -// NameId[Index].PinData.ImageType[j], NameId[Index].PinData.Index[j], -// VoltReq, SOURCE_PROGRAM_MAIN, &ImageStack[k].Image->Images); -// NameId[Index].PinData.ProgVolt = NameId[Index].PinData.Volt; - -// } -// } -// } -// } - -// } - -void TranslateState(char *name, BOOL state) -{ - double VoltReq; - UINT i; - VoltReq = (double) (state ? VOLT_5 : GND); - for(i=0; i<NameCount; i++) - { - if((strcmp(NameId[i].Name, name)) == 0) - { - // CreateVoltRequest(i,VoltReq); - /*NameId[i].PinData.ProgVolt = RefreshVolt( - NameId[i].PinId, NULL, i, NULL, VoltReq);*/ - if((NameId[i].PinData.ProgVolt > VoltReq) || - (NameId[i].PinData.ProgComponent == &MainProgramComponent) || - (NameId[i].PinData.ProgComponent == NULL)) - { - NameId[i].PinData.ProgComponent = &MainProgramComponent; - if(VoltReq <= NameId[i].PinData.Volt) - { - NameId[i].PinData.ProgVolt = VoltReq; - /*char vx[3],vy[10]; - _gcvt(NameId[i].PinData.ProgVolt,10,vy); - _itoa(NameId[i].PinId,vx,10); - MessageBox(AdvancedDialog, - _(vy), _(NameId[i].Name), MB_OK | MB_ICONWARNING);*/ - /*sprintf_s(Debug, "Executing1: \t ProgVoltage:%f\n", - NameId[Id].PinData.ProgVolt); - OutputDebugString(Debug);*/ - } - else - { - NameId[i].PinData.ProgVolt = NameId[i].PinData.Volt; - /*sprintf_s(Debug, "Executing2: \tVoltage:%f\n", - NameId[Id].PinData.Volt); - OutputDebugString(Debug);*/ - } - RefreshVolt(NameId[i].PinId, NULL, i, NULL, VoltReq); - /*sprintf_s(Debug, "Executing3: \t ProgVoltage:%f\n", - NameId[Id].PinData.ProgVolt); - OutputDebugString(Debug);*/ - } - /*char Debug[256]; - sprintf_s(Debug, "TranslateState: %s: %f \n", name, VoltReq); - OutputDebugString(Debug);*/ - } - } -} - -void MCUPinState(char *name, BOOL state) -{ - double volt = (double) state?VOLT_5:GND; - for(UINT i=0; i<NameCount; i++) - { - if((strcmp(NameId[i].Name, name)) == 0) - { - NameId[i].PinData.ProgVolt = volt; - } - } -} - -int IsMCUPin(int PinId) -{ - UINT i; - for(i=0; i<MCUCount; i++) - { - if(McuPin[i].PinId == PinId) - { - return i; - } - } - return -1; -} - -/*double RequestVoltChange(int PinId, void *ComponentAddress, double volt) -{ - // Compare NameId.PinData.Imageid with component address, - and notify all other components of voltage change - char* Name; - int Pin; - // MessageBox(AdvancedDialog, "Test", "Pullup", MB_OK | MB_ICONWARNING); - for(unsigned int i =0;i<NameCount;i++) - { - if((NameId[i].PinId == PinId)) - { - /*char vx[3],vy[10]; - _gcvt(NameId[i].PinData.Volt,10,vy); - _itoa(PinId,vx,10); - MessageBox(AdvancedDialog, - _(vx), _(vy), MB_OK | MB_ICONWARNING); - if(NameId[i].PinData.Volt <= volt) - { - // MessageBox(NULL, "Returning", "Mouse Clicked", - MB_OK | MB_ICONWARNING); - return NameId[i].PinData.Volt; - } - Name = (char*)&NameId[i].Name; - int num = NameId[i].PinData.LinkCount; - Pin = i; - for(int j=0;j<num;j++) - { - if(!(ComponentAddress == NameId[i].PinData.ImageId[j])) - { - for(int k =0; k<ImagesDrawn; k++) - { - if(ImageStack[k].Properties == ComponentAddress) - { - if((NameId[i].PinData.ProgVolt > volt)) - { - NameId[i].PinData.ProgVolt = VoltRequest( - NameId[i].PinData.ImageId[j], - SimulationStarted, - NameId[i].PinData.ImageType[j], - NameId[i].PinData.Index[j], - volt, SOURCE_FORCE_MAIN, - ImageStack[k].Image->Images); - NameId[i].PinData.ProgComponent = - ComponentAddress; - char Debug[256]; - sprintf_s(Debug, "1Name:%s \t ProgVolt:%f \t Volt:%f \t RVolt: %f\n", Name, - NameId[i].PinData.ProgVolt,NameId[i].PinData.Volt,volt); - OutputDebugString(Debug); - } - else if((NameId[i].PinData.ProgVolt < volt)) - { - if( - (NameId[i].PinData.ProgComponent == - ComponentAddress) || - NameId[i].PinData.ProgComponent == NULL) - { - // MessageBox(AdvancedDialog, "Set", - "Mouse Clicked", - MB_OK | MB_ICONWARNING); - NameId[i].PinData.ProgVolt = VoltRequest( - NameId[i].PinData.ImageId[j], - SimulationStarted, - NameId[i].PinData.ImageType[j], - NameId[i].PinData.Index[j], volt, - SOURCE_FORCE_MAIN, - ImageStack[k].Image->Images); - char Debug[256]; - sprintf_s(Debug, "2Name:%s \t ProgVolt:%f \t Volt:%f \t RVolt: %f\n", Name, - NameId[i].PinData.ProgVolt,NameId[i].PinData.Volt,volt); - OutputDebugString(Debug); - } - } - } - } - } - else - { - if((NameId[i].PinData.ProgComponent == ComponentAddress)) - { - // MessageBox(AdvancedDialog, "Set", "Test", - MB_OK | MB_ICONWARNING); - for(int k =0; k<ImagesDrawn; k++) - { - if(ImageStack[k].Properties == ComponentAddress) - { - NameId[i].PinData.ProgVolt = VoltRequest( - NameId[i].PinData.ImageId[j], - SimulationStarted, - NameId[i].PinData.ImageType[j], - NameId[i].PinData.Index[j], - volt, SOURCE_FORCE_MAIN, - ImageStack[k].Image->Images); - NameId[i].PinData.ProgComponent = - ComponentAddress; - } - } - char Debug[256]; - sprintf_s(Debug, "3Name:%s \t ProgVolt:%f \t Volt:%f \t RVolt: %f\n", Name, - NameId[i].PinData.ProgVolt,NameId[i].PinData.Volt,volt); - OutputDebugString(Debug); - } - else if(NameId[i].PinData.ProgComponent == NULL) - { - NameId[i].PinData.ProgVolt = volt; - NameId[i].PinData.ProgComponent = ComponentAddress; - } - } - } - } - } - int Index; - Index = IsMCUPin(PinId); - if(Index >=0) - { - if(McuPin[Index].type == IO_TYPE_DIG_INPUT) - { - if(NameId[Pin].PinData.ProgVolt == VOLT_5) - { - SimulationSetContact(Name); - // MessageBox(AdvancedDialog, "Set", "Mouse Clicked", - MB_OK | MB_ICONWARNING); - } - else if(NameId[Pin].PinData.ProgVolt == GND) - { - SimulationResetContact(Name); - // MessageBox(AdvancedDialog, "Reset", "Mouse Clicked", - MB_OK | MB_ICONWARNING); - } - else if(NameId[Pin].PinData.ProgVolt == V_OPEN) - { - if(McuPin[Index].InternalPullup) - { - NameId[Pin].PinData.ProgVolt = VOLT_5; - SimulationSetContact(Name); - // MessageBox(AdvancedDialog, "Set", "Pullup", - MB_OK | MB_ICONWARNING); - } - else - { - SimulationResetContact(Name); - // MessageBox(AdvancedDialog, "Set", "Pullup", - MB_OK | MB_ICONWARNING); - } - } - } - // char Debug[256]; - // sprintf_s(Debug, "Name:%s \t ProgVolt:%f \t Volt:%f \n", Name, - NameId[Index].PinData.ProgVolt,NameId[Index].PinData.Volt); - // OutputDebugString(Debug); - } - if(NameId[Pin].PinData.ProgVolt > NameId[Pin].PinData.Volt) - { - NameId[Pin].PinData.ProgVolt = NameId[Pin].PinData.Volt; - char Debug[256]; - sprintf_s(Debug, "4Name:%s \t ProgVolt:%f \t Volt:%f \t RVolt: %f\n", Name, - NameId[Pin].PinData.ProgVolt,NameId[Pin].PinData.Volt,volt); - OutputDebugString(Debug); - } - else - { - char Debug[256]; - sprintf_s(Debug, "5Name:%s \t ProgVolt:%f \t Volt:%f \t RVolt: %f\n", Name, - NameId[Pin].PinData.ProgVolt,NameId[Pin].PinData.Volt,volt); - OutputDebugString(Debug); - } - char vx[10],vy[10]; - _gcvt(NameId[Pin].PinData.ProgVolt,8,vy); - _itoa(Pin,vx,2); - MessageBox(AdvancedDialog, - Name, _(vy), MB_OK | MB_ICONWARNING); - return NameId[Pin].PinData.ProgVolt; -}*/ - -double RequestVoltChange(int PinId, int Index, - void *ComponentAddress, double volt) -{ - UINT Id; - double temp; - // char Debug[1024]; - for(UINT i=0; i<NameCount; i++) - { - if(NameId[i].PinId == PinId) - { - Id = i; - break; - } - } - // if(Id >= NameCount) - // { - // sprintf_s(Debug, "PinId Not found %s: %d\n", - // NameId[Id].Name, PinId); - // OutputDebugString(Debug); - // } - temp = NameId[Id].PinData.ProgVolt; - - /*sprintf_s(Debug, "Changing Voltage %s: %f to %f \t ProgVolt:\ - %f \tChanger: %p\n", - NameId[Id].Name, temp, volt, NameId[Id].PinData.ProgVolt, - NameId[Id].PinData.ProgComponent); - OutputDebugString(Debug);*/ - if((NameId[Id].PinData.ProgVolt > volt) || - (NameId[Id].PinData.ProgComponent == ComponentAddress) || - (NameId[Id].PinData.ProgComponent == NULL)) - { - NameId[Id].PinData.ProgComponent = ComponentAddress; - if(volt <= NameId[Id].PinData.Volt) - { - NameId[Id].PinData.ProgVolt = volt; - /*sprintf_s(Debug, "Executing1: \t ProgVoltage:%f\n", - NameId[Id].PinData.ProgVolt); - OutputDebugString(Debug);*/ - } - else - { - NameId[Id].PinData.ProgVolt = NameId[Id].PinData.Volt; - /*sprintf_s(Debug, "Executing2: \tVoltage:%f\n", - NameId[Id].PinData.Volt); - OutputDebugString(Debug);*/ - } - RefreshVolt(PinId, Index, Id, ComponentAddress, - NameId[Id].PinData.ProgVolt); - /*sprintf_s(Debug, "Executing3: \t ProgVoltage:%f\n", - NameId[Id].PinData.ProgVolt); - OutputDebugString(Debug);*/ - } - RefreshProcessorStat(PinId, Id); - /*sprintf_s(Debug, "Final Voltage %s: %f to %f \t ProgVolt:\ - %f \tChanger: %p\n", - NameId[Id].Name, temp, volt, NameId[Id].PinData.ProgVolt, - NameId[Id].PinData.ProgComponent); - OutputDebugString(Debug);*/ - return NameId[Id].PinData.ProgVolt; -} - -double RefreshVolt(int PinId, int Index, UINT Id, - void* ComponentAddress, double volt) -{ - // char Debug[1024]; - double FinalVolt = volt; - /*sprintf_s(Debug, "Executing4: \t ProgVoltage:%f\n", - NameId[Id].PinData.ProgVolt); - OutputDebugString(Debug);*/ - for(int i=0; i<NameId[Id].PinData.LinkCount;i++) - { - /*sprintf_s(Debug, "Currently processing: %s \tComponentAddress:%p\ - \tIndex:%d \tRequested by: %p,Index:%d\n", - NameId[Id].Name, NameId[Id].PinData.ImageId[i], - NameId[Id].PinData.Index[i],ComponentAddress, Index); - OutputDebugString(Debug);*/ - if(!(NameId[Id].PinData.ImageId[i] == ComponentAddress)) - { - /*sprintf_s(Debug, "Executing5: \t ProgVoltage:%f\n", - NameId[Id].PinData.ProgVolt); - OutputDebugString(Debug);*/ - for(int k =0; k<ImagesDrawn; k++) - { - if((ImageStack[k].Properties == NameId[Id].PinData.ImageId[i])) - { - /*sprintf_s(Debug, "Requesting Voltage %s: %f to \ - %f \tProgVolt: %f \tComponentAddress:%p, Index: %d\n", - NameId[Id].Name, volt, FinalVolt, - NameId[Id].PinData.ProgVolt, - NameId[Id].PinData.ImageId[i], - NameId[Id].PinData.Index[i]); - OutputDebugString(Debug);*/ - /*if(ComponentAddress == NULL) - { - char vx[sizeof(int)*8+1],vy[10]; - _gcvt(NameId[Id].PinData.ProgVolt,10,vy); - // if(NameId[Id].PinData.Index) - _itoa(ImageStack[i].Image->ComponentId,vx,10); - MessageBox(AdvancedDialog, - (LPSTR)(vx), (LPSTR)(NameId[Id].Name), MB_OK | MB_ICONWARNING); - }*/ - - FinalVolt = VoltSet(NameId[Id].PinData.ImageId[i], - SimulationStarted, ImageStack[k].Image->ComponentId, - NameId[Id].PinData.Index[i], - NameId[Id].PinData.ProgVolt, - SOURCE_PROGRAM_MAIN, &ImageStack[k].Image->Images); - if(FinalVolt < NameId[Id].PinData.ProgVolt) - { - NameId[Id].PinData.ProgVolt = FinalVolt; - NameId[Id].PinData.ProgComponent = - ImageStack[k].Properties; - /*sprintf_s(Debug, "Executing7: \t \ - ProgVoltage:%f\n",NameId[Id].PinData.ProgVolt); - OutputDebugString(Debug);*/ - } - else - { - if(ImageStack[k].Properties == - NameId[Id].PinData.ProgComponent) - { - NameId[Id].PinData.ProgVolt = FinalVolt; - NameId[Id].PinData.ProgComponent = - ImageStack[k].Properties; - /*sprintf_s(Debug, "Executing8: \t ProgVoltage:\ - %f\n",NameId[Id].PinData.ProgVolt); - OutputDebugString(Debug);*/ - } - } - if(NameId[Id].PinData.ProgVolt > NameId[Id].PinData.Volt) - { - NameId[Id].PinData.ProgVolt = NameId[Id].PinData.Volt; - } - /*sprintf_s(Debug, "Updating Voltage %s: %f to \ - %f \tProgVolt: %f\n",NameId[Id].Name, - volt,FinalVolt,NameId[Id].PinData.ProgVolt); - OutputDebugString(Debug);*/ - } - } - } - } - /*sprintf_s(Debug, "Executing:10 \t ProgVoltage:\ - %f\n",NameId[Id].PinData.ProgVolt); - OutputDebugString(Debug);*/ - RefreshProcessorStat(PinId, Id); - /*if(ComponentAddress == NULL) - { - char vx[10],vy[10]; - _gcvt(NameId[Id].PinData.ProgVolt,10,vy); - _itoa(NameId[Id].PinId,vx,10); - MessageBox(AdvancedDialog, - (LPSTR)(vx), (LPSTR)(NameId[Id].Name), MB_OK | MB_ICONWARNING); - }*/ - /*sprintf_s(Debug, "Executing11: \t ProgVoltage:%f\n", - NameId[Id].PinData.ProgVolt); - OutputDebugString(Debug);*/ - return NameId[Id].PinData.ProgVolt; -} -double RefreshProcessorStat(int PinId, UINT Id) -{ - char* Name; - // char Debug[256]; - int MCUPinId; - MCUPinId = IsMCUPin(PinId); - if(MCUPinId >=0) - { - Name = (char*)&NameId[Id].Name; - if(McuPin[MCUPinId].type == IO_TYPE_DIG_INPUT) - { - if(NameId[Id].PinData.ProgVolt == VOLT_5) - { - SimulationSetContact(Name); - // MessageBox(AdvancedDialog, "Set", - // "Mouse Clicked", MB_OK | MB_ICONWARNING); - } - else if(NameId[Id].PinData.ProgVolt == GND) - { - SimulationResetContact(Name); - // MessageBox(AdvancedDialog, "Reset", - // "Mouse Clicked", MB_OK | MB_ICONWARNING); - } - else if(NameId[Id].PinData.ProgVolt == V_OPEN) - { - if(McuPin[MCUPinId].InternalPullup) - { - /*sprintf_s(Debug, "Executing21: \t ProgVoltage:%f\n", - NameId[Id].PinData.ProgVolt); - OutputDebugString(Debug);*/ - NameId[Id].PinData.ProgVolt = VOLT_5; - SimulationSetContact(Name); - // MessageBox(AdvancedDialog, "Set", "Pullup",\ - // MB_OK | MB_ICONWARNING); - } - else - { - SimulationResetContact(Name); - // MessageBox(AdvancedDialog, "Set", "Pullup", - // MB_OK | MB_ICONWARNING); - } - } - } - } - else - { - if(NameId[Id].PinData.ProgVolt > NameId[Id].PinData.Volt) - { - /*sprintf_s(Debug, "Executing22: \t ProgVoltage:%f\n", - NameId[Id].PinData.ProgVolt); - OutputDebugString(Debug);*/ - NameId[Id].PinData.ProgVolt = NameId[Id].PinData.Volt; - } - } - /*sprintf_s(Debug, "Executing23: \t ProgVoltage:%f\n", - NameId[Id].PinData.ProgVolt); - OutputDebugString(Debug);*/ - return NameId[Id].PinData.ProgVolt; -} - -double GetGlobalVoltage(int PinId, void* ComponentAddress) -{ - int MCUPinId = IsMCUPin(PinId); - for(UINT i=0; i<NameCount; i++) - { - if(NameId[i].PinId == PinId) - { - /*char Debug[256]; - sprintf_s(Debug, "GetGlobalVoltage: %s\n", - NameId[i].Name); - OutputDebugString(Debug);*/ - if(MCUPinId >=0) - { - if(McuPin[MCUPinId].type == IO_TYPE_DIG_INPUT) - { - if(ComponentAddress == NameId[i].PinData.ProgComponent) - { - return VOLT_5; - } - } - } - return NameId[i].PinData.ProgVolt; - } - } - return GND - 1; -} -// int RegisterPinState(int Index, double Volt) -// { -// PinData[Index].McuPin = TRUE; -// return 0; -// } - -/*void RefreshDialogScrollbars(void) -{ - SCROLLINFO vert, horiz; - SetUpScrollbars(&NeedHoriz, &horiz, &vert); - SetScrollInfo(HorizScrollBar, SB_CTL, &horiz, TRUE); - SetScrollInfo(VertScrollBar, SB_CTL, &vert, TRUE); - - RECT main; - GetClientRect(AdvancedWorkspace, &main); - - if(NeedHoriz) { - MoveWindow(HorizScrollBar, 0, IoListTop - ScrollHeight - 2, - main.right - ScrollWidth - 2, ScrollHeight, TRUE); - ShowWindow(HorizScrollBar, SW_SHOW); - EnableWindow(HorizScrollBar, TRUE); - } else { - ShowWindow(HorizScrollBar, SW_HIDE); - } - MoveWindow(VertScrollBar, main.right - ScrollWidth - 2, 1, ScrollWidth, - NeedHoriz ? (IoListTop - ScrollHeight - 4) : (IoListTop - 3), TRUE); - - MoveWindow(VertScrollBar, main.right - ScrollWidth - 2, 1, ScrollWidth, - NeedHoriz ? (IoListTop - ScrollHeight - 4) : (IoListTop - 3), TRUE); - - InvalidateRect(AdvancedDialog, NULL, FALSE); -}*/
\ No newline at end of file diff --git a/ldmicro/ansic.cpp b/ldmicro/ansic.cpp index d0fe240..ca13836 100644 --- a/ldmicro/ansic.cpp +++ b/ldmicro/ansic.cpp @@ -22,7 +22,7 @@ // responsible for calling us with appropriate timing. // Jonathan Westhues, Oct 2004 //----------------------------------------------------------------------------- -#include <windows.h> +#include "linuxUI.h" #include <stdio.h> #include <setjmp.h> #include <stdlib.h> diff --git a/ldmicro/arduino.cpp b/ldmicro/arduino.cpp index 0e1db36..af8090b 100644 --- a/ldmicro/arduino.cpp +++ b/ldmicro/arduino.cpp @@ -4,7 +4,7 @@ // runtime needed to schedule the cycles. // Jonathan Westhues, Oct 2004 //----------------------------------------------------------------------------- -#include <windows.h> +#include <linuxUI.h> #include <stdio.h> #include <setjmp.h> #include <stdlib.h> diff --git a/ldmicro/avr.cpp b/ldmicro/avr.cpp index e4e2bc9..848426d 100644 --- a/ldmicro/avr.cpp +++ b/ldmicro/avr.cpp @@ -22,7 +22,7 @@ // runtime needed to schedule the cycles. // Jonathan Westhues, Oct 2004 //----------------------------------------------------------------------------- -#include <windows.h> +#include <linuxUI.h> #include <stdio.h> #include <setjmp.h> #include <stdlib.h> diff --git a/ldmicro/circuit.cpp b/ldmicro/circuit.cpp index 82d8414..1d9d3d7 100644 --- a/ldmicro/circuit.cpp +++ b/ldmicro/circuit.cpp @@ -21,7 +21,7 @@ // particular point, delete the selected element, etc. // Jonathan Westhues, Oct 2004 //----------------------------------------------------------------------------- -#include <windows.h> +#include <linuxUI.h> #include <stdio.h> #include <stdlib.h> diff --git a/ldmicro/coildialog.cpp b/ldmicro/coildialog.cpp index fa4228c..070dd42 100644 --- a/ldmicro/coildialog.cpp +++ b/ldmicro/coildialog.cpp @@ -21,9 +21,9 @@ // plus the name, plus set-only or reset-only // Jonathan Westhues, Oct 2004 //----------------------------------------------------------------------------- -#include <windows.h> +#include <linuxUI.h> #include <stdio.h> -#include <commctrl.h> +//#include <commctrl.h> #include "ldmicro.h" diff --git a/ldmicro/commentdialog.cpp b/ldmicro/commentdialog.cpp index a1f1e06..4cfe13b 100644 --- a/ldmicro/commentdialog.cpp +++ b/ldmicro/commentdialog.cpp @@ -21,9 +21,9 @@ // encourage people to write it the way it will look on the diagram. // Jonathan Westhues, Jun 2005 //----------------------------------------------------------------------------- -#include <windows.h> +#include <linuxUI.h> #include <stdio.h> -#include <commctrl.h> +//#include <commctrl.h> #include "ldmicro.h" diff --git a/ldmicro/compilecommon.cpp b/ldmicro/compilecommon.cpp index f9f1206..a25d742 100644 --- a/ldmicro/compilecommon.cpp +++ b/ldmicro/compilecommon.cpp @@ -20,7 +20,7 @@ // Routines common to the code generators for all processor architectures. // Jonathan Westhues, Nov 2004 //----------------------------------------------------------------------------- -#include <windows.h> +#include <linuxUI.h> #include <stdio.h> #include <stdlib.h> diff --git a/ldmicro/componentimages.cpp b/ldmicro/componentimages.cpp deleted file mode 100644 index 2026c7f..0000000 --- a/ldmicro/componentimages.cpp +++ /dev/null @@ -1,253 +0,0 @@ - -#include <windows.h> -#include <commctrl.h> -#include <stdio.h> -#include <stdlib.h> -#include <wincodec.h> - -#include "ldmicro.h" -#include "componentlist.h" -#include "components/componentimages.h" - -static int temp = 1; - -void InitializeComponentImage(int Component, HIMAGELIST *il) -{ - int i; - // char a[4]; - // MessageBox(ComponentList, (LPCTSTR)itoa(rgCompData[Component], a, 10), - // "Info", MB_OK | MB_ICONEXCLAMATION); - // test=LoadComponentImage(rgCompData[Component].Images[0]); - // if(test ==NULL){ - // MessageBox(ComponentList, "Could not load Bitmap!", - // "Error", MB_OK | MB_ICONEXCLAMATION); - // } - // HDC hdc=GetDC(AdvancedWorkspace); - // HdcMem = CreateCompatibleDC(hdc); - // HBITMAP bm = (HBITMAP)SelectObject(HdcMem, test); - // BitBlt(hdc, 10 * temp, 10 * temp, COMPONENT_WIDTH, - // COMPONENT_HEIGHT, HdcMem, 0, 0, SRCCOPY); - // temp++; - // DeleteDC(hdc); - // if(ComponentDiagrams == NULL){ - // InitializeImageList(); - // } - HBITMAP bm = LoadComponentImage(Component); - // HBITMAP mask = CreateBitmapMask(bm, CLR_NONE); - // HDC hdc = GetDC(AdvancedWorkspace); - ImageList_RemoveAll(*il); - i = ImageList_AddMasked(*il, bm, CLR_NONE); - if(bm==NULL) - { - MessageBox(NULL,"Could not add image", - "Info", MB_OK | MB_ICONEXCLAMATION); - } - /*char vx[4],vy[4]; - _itoa(10,vy,10); - _itoa(ImageStack[i].Image->Images,vx,10); - MessageBox(NULL, - (vx), (vy), MB_OK | MB_ICONWARNING);*/ - // _itoa(Component, a, 10); - // MessageBox(ComponentList,a, - // "Info", MB_OK | MB_ICONEXCLAMATION); - - // ImageList_Draw(ComponentDiagrams, i, hdc, 100*temp, 100*temp, ILD_TRANSPARENT); - // temp ++; - // DeleteDC(hdc); -} - -//----------------------------------------------------------------------------- -// Creates a stream object initialized with the data from an executable resource. -//----------------------------------------------------------------------------- - -IStream * CreateStreamOnResource(LPCTSTR lpName, LPCTSTR lpType) -{ - - // initialize return value - IStream * ipStream = NULL; - - // find the resource - HRSRC hrsrc = FindResource(NULL, lpName, lpType); - if (hrsrc == NULL) - { - return ipStream; - } - - // load the resource - DWORD dwResourceSize = SizeofResource(NULL, hrsrc); - HGLOBAL hglbImage = LoadResource(NULL, hrsrc); - if (hglbImage == NULL) - { - return ipStream; - } - - // lock the resource, getting a pointer to its data - LPVOID pvSourceResourceData = LockResource(hglbImage); - if (pvSourceResourceData == NULL) - { - return ipStream; - } - - // allocate memory to hold the resource data - HGLOBAL hgblResourceData = GlobalAlloc(GMEM_MOVEABLE, dwResourceSize); - if (hgblResourceData == NULL) - { - return ipStream; - } - - // get a pointer to the allocated memory - LPVOID pvResourceData = GlobalLock(hgblResourceData); - if (pvResourceData == NULL) - { - // couldn't create stream; free the memory - GlobalFree(hgblResourceData); - return ipStream; - } - - // copy the data from the resource to the new memory block - CopyMemory(pvResourceData, pvSourceResourceData, dwResourceSize); - GlobalUnlock(hgblResourceData); - - // create a stream on the HGLOBAL containing the data - if (SUCCEEDED(CreateStreamOnHGlobal(hgblResourceData, TRUE, &ipStream))) - { - return ipStream; - } - GlobalFree(hgblResourceData); - return ipStream; -} - -//----------------------------------------------------------------------------- -// Loads a PNG image from the specified stream -// (using Windows Imaging Component) -//----------------------------------------------------------------------------- -IWICBitmapSource * LoadBitmapFromStream(IStream * ipImageStream) -{ - // initialize return value - IWICBitmapSource * ipBitmap = NULL; - - // load WIC's PNG decoder - IWICBitmapDecoder * ipDecoder = NULL; - if(CoInitialize(NULL) == RPC_E_CHANGED_MODE) - { - MessageBox(ComponentList, "Could not Initialize COM Library!", - "Error", MB_OK | MB_ICONEXCLAMATION); - } - if (FAILED(CoCreateInstance(CLSID_WICPngDecoder, NULL, CLSCTX_INPROC_SERVER, - __uuidof(ipDecoder), reinterpret_cast<void**>(&ipDecoder)))) - { - MessageBox(ComponentList, "Could not Create Object!", - "Error", MB_OK | MB_ICONEXCLAMATION); - goto Return; - } - - // load the PNG - if (FAILED(ipDecoder->Initialize(ipImageStream, WICDecodeMetadataCacheOnLoad))) - goto ReleaseDecoder; - - // check for the presence of the first frame in the bitmap - UINT nFrameCount = 0; - if (FAILED(ipDecoder->GetFrameCount(&nFrameCount)) || nFrameCount != 1) - goto ReleaseDecoder; - - // load the first frame (i.e., the image) - IWICBitmapFrameDecode * ipFrame = NULL; - if (FAILED(ipDecoder->GetFrame(0, &ipFrame))) - goto ReleaseDecoder; - - // convert the image to 32bpp BGRA format with pre-multiplied alpha - // (it may not be stored in that format natively in the PNG resource, - // but we need this format to create the DIB to use on-screen) - WICConvertBitmapSource(GUID_WICPixelFormat32bppPBGRA, ipFrame, &ipBitmap); - ipFrame->Release(); - -ReleaseDecoder: - ipDecoder->Release(); - -Return: - return ipBitmap; - -} - -//----------------------------------------------------------------------------- -// Creates a 32-bit DIB from the specified WIC bitmap. -//----------------------------------------------------------------------------- - -HBITMAP CreateHBITMAP(IWICBitmapSource * ipBitmap) -{ - // initialize return value - HBITMAP hbmp = NULL; - - // get image attributes and check for valid image - UINT width = 0; - UINT height = 0; - if (FAILED(ipBitmap->GetSize(&width, &height)) || width == 0 || height == 0) - { - return hbmp; - } - - // prepare structure giving bitmap information - // (negative height indicates a top-down DIB) - BITMAPINFO bminfo; - ZeroMemory(&bminfo, sizeof(bminfo)); - bminfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - bminfo.bmiHeader.biWidth = width; - bminfo.bmiHeader.biHeight = -((LONG) height); - bminfo.bmiHeader.biPlanes = 1; - bminfo.bmiHeader.biBitCount = 32; - bminfo.bmiHeader.biCompression = BI_RGB; - - // create a DIB section that can hold the image - void * pvImageBits = NULL; - HDC hdcScreen = GetDC(NULL); - hbmp = CreateDIBSection(hdcScreen, &bminfo, DIB_RGB_COLORS, &pvImageBits, NULL, 0); - ReleaseDC(NULL, hdcScreen); - if (hbmp == NULL) - { - return hbmp; - } - - // extract the image into the HBITMAP - const UINT cbStride = width * 4; - const UINT cbImage = cbStride * height; - if (FAILED(ipBitmap->CopyPixels(NULL, cbStride, cbImage, static_cast<BYTE *>(pvImageBits)))) - { - // couldn't extract image; delete HBITMAP - DeleteObject(hbmp); - hbmp = NULL; - } - - return hbmp; -} - -//----------------------------------------------------------------------------- -// Loads the PNG containing the splash image into a HBITMAP. -//----------------------------------------------------------------------------- - -HBITMAP LoadComponentImage(int resource) -{ - HBITMAP hbmpSplash = NULL; - - // load the PNG image data into a stream - IStream * ipImageStream = CreateStreamOnResource( - MAKEINTRESOURCE(resource), _("PNG")); - if (ipImageStream == NULL) - { - return hbmpSplash; - } - - // load the bitmap with WIC - IWICBitmapSource * ipBitmap = LoadBitmapFromStream(ipImageStream); - if (ipBitmap == NULL) - { - ipImageStream->Release(); - return hbmpSplash; - } - - // create a HBITMAP containing the image - hbmpSplash = CreateHBITMAP(ipBitmap); - ipBitmap->Release(); - - ipImageStream->Release(); - return hbmpSplash; -}
\ No newline at end of file diff --git a/ldmicro/componentlist.cpp b/ldmicro/componentlist.cpp deleted file mode 100644 index 97c5b7e..0000000 --- a/ldmicro/componentlist.cpp +++ /dev/null @@ -1,208 +0,0 @@ -#include <windows.h> -#include <commctrl.h> -#include <stdio.h> -#include <stdlib.h> -#include <wincodec.h> - -#include "ldmicro.h" -#include "advanceddialog.h" -#include "componentlist.h" -#include "components\componentimages.h" -#include "components\components.h" - -// I/O that we have seen recently, so that we don't forget pin assignments -// when we re-extract the list - -// static HBITMAP testmask=NULL; - -HIMAGELIST ComponentDiagrams; -static int ComponentCount; -ImageLocation ImageStack[MAX_SCREEN_ITEMS]; -PinInfo PinStack[MAX_PINS]; -int ImagesDrawn = 0; -int DragIndex = 0; -int DragOffsetX = 0; -int DragOffsetY = 0; -int DragX = 0; -int DragY = 0; -BOOL Dragging = FALSE; -UINT UniqueImgId = 0; - -// Imagemap test; - -void ComponentListInitiate(void) -{ - int i; - LVITEM lvi; - for(i = 0; i < TOTAL_COMPONENTS; i++) - { - lvi.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE; - lvi.state = lvi.stateMask = 0; - lvi.iItem = i; - lvi.iSubItem = 0; - lvi.pszText = rgCompData[i].ComponentName; - lvi.lParam = rgCompData[i].Index; - if(ListView_InsertItem(ComponentList, &lvi) < 0) oops(); - } - // test.insert(make_pair(1, ComponentDiagrams, 100, 100, 6000)); -} - -void ComponentListProc(NMHDR *h) -{ - switch(h->code) { - case LVN_ITEMACTIVATE: - { - int Img, Index; - NMITEMACTIVATE *i = (NMITEMACTIVATE *)h; - LVITEM lvi; - lvi.mask = LVIF_PARAM; - lvi.iItem = ListView_GetNextItem(ComponentList, -1, LVNI_SELECTED); - ListView_GetItem(ComponentList, &lvi); - Index = (int) lvi.lParam; - int CompId = rgCompData[Index].ComponentId; - ImageStack[ImagesDrawn].Image = - (ImageStruct *)AllocImageHeap(sizeof(ImageStruct)); - ImageStack[ImagesDrawn].Image->ComponentId = CompId; - ImageStack[ImagesDrawn].Properties = - AllocImageHeap(GetStructSize(CompId)); - ImageStack[ImagesDrawn].PinName = - AllocImageHeap(GetNameSize(Index)); - ImageStack[ImagesDrawn].Id = ++UniqueImgId; - ImageStack[ImagesDrawn].Index = Index; - Img = InitializeComponentProperties( - ImageStack[ImagesDrawn].Properties, CompId); - InitializeImageList(&ImageStack[ImagesDrawn].Image->Images); - InitializeComponentImage(Img, - &ImageStack[ImagesDrawn].Image->Images); - ImageStack[ImagesDrawn].x = 100; - ImageStack[ImagesDrawn].y = 100; - // RECT TempRect; - // GetWindowRect(AdvancedWorkspace, &TempRect); - InvalidateRect(AdvancedWorkspace, NULL, TRUE); - - ImagesDrawn++; - // char a[4]; - // MessageBox(ComponentList, (LPCTSTR)itoa(lvi.lParam, a, 10), "Info", MB_OK | MB_ICONEXCLAMATION); - // InitializeComponentImage((int)lvi.lParam); - // int *temp; - // temp = (int *)i->lParam; - // MessageBox(ComponentList, (LPCTSTR)itoa(*temp, a, 10), "Info", MB_OK | MB_ICONEXCLAMATION); - //Selection Code Here - - // test=LoadComponentImage(RELAY_NC); - // if(test ==NULL){ - // MessageBox(ComponentList, "Could not load Bitmap!", "Error", MB_OK | MB_ICONEXCLAMATION); - // } - } - break; - default: - break; - } -} - -void InitializeImageList(HIMAGELIST *il) -{ - *il = ImageList_Create(COMPONENT_WIDTH, COMPONENT_HEIGHT, ILC_MASK | ILC_COLOR8, 0, MAX_SCREEN_ITEMS); - if(*il == NULL){ - MessageBox(ComponentList, "Could not Initialize ImageList", "Error", MB_OK | MB_ICONEXCLAMATION); - return; - } -} - -void RefreshImages() -{ - InvalidateRect(AdvancedWorkspace, NULL, TRUE); -} - -void SetImage(int Component, void *il) -{ - InitializeComponentImage(Component,(HIMAGELIST*) il); -} - -int BeginComponentDrag(int x, int y) -{ - int i; - for(i = 0; i < ImagesDrawn; i++) - { - if((((ImageStack[i].x + COMPONENT_WIDTH) > x) && (ImageStack[i].x < x) - && (ImageStack[i].y < y) && ((ImageStack[i].y + COMPONENT_HEIGHT) > y))) - { - // RECT TempRect; - // TempRect.left = ImageStack[i].x; - // TempRect.top = ImageStack[i].y; - // TempRect.right = ImageStack[i].x + 100; - // TempRect.bottom = ImageStack[i].y + 100; - - DragOffsetX = x - ImageStack[i].x; - DragOffsetY = y - ImageStack[i].y; - DragX = x; - DragY = y; - - // MessageBox(ComponentList, "Clicked Image", "Error", MB_OK | MB_ICONEXCLAMATION); - ImageList_BeginDrag(ImageStack[i].Image->Images, 0, DragOffsetX, DragOffsetY); - ImageList_SetDragCursorImage(ImageStack[i].Image->Images, 0, 0, 0); - ImageList_DragEnter(AdvancedWorkspace, x, y); - - // ImageStack[i].x = -200; - // ImageStack[i].y = -200; - // InvalidateRect(AdvancedWorkspace, &TempRect, TRUE); - DragIndex = i; - Dragging = TRUE; - return 0; - } - } - // HBITMAP temp=(HBITMAP)GetCurrentObject(GetDC(AdvancedWorkspace), OBJ_BITMAP); - // if(temp == NULL) - // { - // MessageBox(ComponentList, "Bitmap Found", "Information", MB_OK | MB_ICONEXCLAMATION); - // } - return 0; -} -int ComponentDrag(int x, int y) -{ - if(Dragging) - { - ImageList_DragMove(x, y); - // ImageStack[DragIndex].x = x - DragOffsetX; - // ImageStack[DragIndex].y = y - DragOffsetY; - // InvalidateRect(AdvancedWorkspace, NULL, TRUE); - } - else - { - SetCursor(LoadCursor(NULL, IDC_ARROW)); - } - return 0; -} - -int EndComponentDrag(int x, int y) -{ - if(Dragging) - { - // HBITMAP TempBM; - // HDC HdcMem2 = GetDC(AdvancedWorkspace); - // HDC HdcMem =GetDC(AdvancedWorkspace); - // RECT TempRect; - // GetWindowRect(AdvancedWorkspace, &TempRect); - ImageList_DragLeave(AdvancedWorkspace); - ImageList_EndDrag(); - ImageStack[DragIndex].x = x - DragOffsetX; - ImageStack[DragIndex].y = y - DragOffsetY; - // InvalidateRect(AdvancedWorkspace, &TempRect, TRUE); - InvalidateRect(AdvancedWorkspace, NULL, TRUE); - // TempBM = CreateBitmap(COMPONENT_WIDTH, COMPONENT_HEIGHT, 1, 32, NULL); - - // BitBlt(HdcMem2, x, y, COMPONENT_WIDTH, COMPONENT_HEIGHT, HdcMem, 100, 100, SRCERASE); - Dragging =FALSE; - return DragIndex; - } - // IMAGEINFO imginfo; - // ImageList_GetImageInfo(ComponentDiagrams,0, &imginfo); - // char vx[4],vy[4]; - // itoa(imginfo.rcImage.right,vx,10); - // itoa(imginfo.rcImage.bottom,vy,10); - // MessageBox(ComponentList, _(vx), _(vy), MB_OK | MB_ICONEXCLAMATION); - // imginfo.rcImage.left=x; - // imginfo.rcImage.top=y; - // ImageList_Draw(ComponentDiagrams, 0, GetDC(AdvancedWorkspace), x, y, ILD_TRANSPARENT); - return NULL; -} diff --git a/ldmicro/components/components.cpp b/ldmicro/components/components.cpp deleted file mode 100644 index 632f136..0000000 --- a/ldmicro/components/components.cpp +++ /dev/null @@ -1,506 +0,0 @@ -#include <wincodec.h> -#include <commctrl.h> -#include <stdio.h> -#include <Windowsx.h> - -#include "components.h" -#include "componentstructs.h" -#include "componentfunctions.h" -// #include <stdio.h> -// #include <stdlib.h> -// #include <setjmp.h> -#include "componentimages.h" -#include "../advanceddialog.h" - -//Component Structure -/*To add am entry in Componentlist on right pane, add entry to this structure as follows: -1. Index of the Component -2. ComponentId created in componentimages.h -3. Text to be displayed -4. No. of pins*/ - -HWND ComponentDialog = NULL; -HWND* MainWindowHandle; -static BOOL DlgDone = FALSE; -static BOOL DlgCancel =FALSE; -static HWND Textboxes[MAX_PIN_COUNT]; -static HWND Labels[MAX_PIN_COUNT]; -int *PinIds; - -void ShowNameDialog(int Index, void* PinName, void* ImageId); -void MakeControls(int Index, int Pins); - -void FontNice(HWND h) -{ - SendMessage(h, WM_SETFONT, (WPARAM)MyNiceFont, TRUE); -} -void FontFixed(HWND h) -{ - SendMessage(h, WM_SETFONT, (WPARAM)MyFixedFont, TRUE); -} - -/*Step : return size of memory required for the component to work.*/ -size_t GetStructSize(int ComponentId) -{ - switch(ComponentId){ - case COMPONENT_SWITCH: - return sizeof(SwitchStruct); - break; - case COMPONENT_RELAY: - return sizeof(RelayStruct); - break; - case COMPONENT_SPDT: - return sizeof(SpdtStruct); - break; - case COMPONENT_DPST: - return sizeof(DpstStruct); - break; - case COMPONENT_DPDT: - return sizeof(DpdtStruct); - break; - } - return (size_t)-1; -} - -/*Step : Initialize Respective component memory with initial parameters before drawing*/ - -int InitializeComponentProperties(void *ComponentAddress, int ComponentId) -{ - switch(ComponentId){ - case COMPONENT_SWITCH: - return InitSwitch(ComponentAddress); - break; - case COMPONENT_RELAY: - return InitRelay(ComponentAddress); - break; - case COMPONENT_SPDT: - return InitSpdt(ComponentAddress); - break; - case COMPONENT_DPST: - return InitDpst(ComponentAddress); - break; - case COMPONENT_DPDT: - return InitDpdt(ComponentAddress); - break; - } - return 0; -} - -// Step : Main Program will Call this function if voltage change event occurs on a pin assigned to a component - -double VoltSet(void* ComponentAddress, BOOL SimulationStarted, int ImageType, int Index, double Volt, - int Source, void* ImageLocation) -{ - - switch(ImageType) - { - case COMPONENT_SWITCH: - return SwitchVoltChanged(ComponentAddress, SimulationStarted, Index, Volt, Source, ImageLocation); - break; - case COMPONENT_RELAY: - return RelayVoltChanged(ComponentAddress, SimulationStarted, Index, Volt, Source, ImageLocation); - break; - case COMPONENT_SPDT: - return SpdtVoltChanged(ComponentAddress, SimulationStarted, Index, Volt, Source, ImageLocation); - break; - case COMPONENT_DPST: - return DpstVoltChanged(ComponentAddress, SimulationStarted, Index, Volt, Source, ImageLocation); - break; - case COMPONENT_DPDT: - return DpdtVoltChanged(ComponentAddress, SimulationStarted, Index, Volt, Source, ImageLocation); - break; - } - return Volt; -} - -void SetPinIds(int Index, void *PinName,int ComponentId, void *ComponentAddress, int Event) -{ - if(Event == EVENT_MOUSE_RCLICK && !SimulationStarted) - { - ShowNameDialog(Index, PinName, ComponentAddress); - switch(ComponentId) - { - case COMPONENT_SWITCH: - SetSwitchIds(PinIds, ComponentAddress); - break; - case COMPONENT_RELAY: - SetRelayIds(PinIds,ComponentAddress); - break; - case COMPONENT_SPDT: - SetSpdtIds(PinIds, ComponentAddress); - break; - case COMPONENT_DPST: - SetDpstIds(PinIds, ComponentAddress); - break; - case COMPONENT_DPDT: - SetDpdtIds(PinIds, ComponentAddress); - break; - } - } -} - -/*Step: Handle events to images displayed on the Dialog*/ - -int NotifyComponent(void *ComponentAddress, void *PinName, int ComponentId, - int Event, BOOL SimulationStarted, HWND* h, int Index, UINT ImageId, void* ImageLocation) -{ - MainWindowHandle = h; - SetPinIds(Index, PinName, ComponentId, ComponentAddress, Event); - /*char Debug[256]; - sprintf_s(Debug, "Notify Component Address: %p\n",ComponentAddress); - OutputDebugString(Debug);*/ - switch(ComponentId){ - case COMPONENT_SWITCH: - HandleSwitchEvent(ComponentAddress, Event, SimulationStarted, ImageLocation, ImageId, h); - /*char vx[10],vy[10]; - _itoa((int) ComponentAddress,vy,10); - _itoa((int)ImageLocation,vx,10); - MessageBox(NULL, - (vx), (vy), MB_OK | MB_ICONWARNING);*/ - return 0; - break; - case COMPONENT_RELAY: - HandleRelayEvent(ComponentAddress, Event, SimulationStarted, ImageLocation, ImageId, h); - // return InitRelay(ComponentAddress); - break; - case COMPONENT_SPDT: - HandleSpdtEvent(ComponentAddress, Event, SimulationStarted, ImageLocation, ImageId, h); - break; - case COMPONENT_DPST: - HandleDpstEvent(ComponentAddress, Event, SimulationStarted, ImageLocation, ImageId, h); - break; - case COMPONENT_DPDT: - HandleDpdtEvent(ComponentAddress, Event, SimulationStarted, ImageLocation, ImageId, h); - break; - } - // return voltage - return 0; -} - - -//----------------------------------------------------------------------------- -// Window procedure to handle DialogBox events -//----------------------------------------------------------------------------- -static LRESULT CALLBACK ComponentDialogProc(HWND hwnd, UINT msg, WPARAM wParam, - LPARAM lParam) -{ - switch (msg) { - case WM_NOTIFY: - break; - - case WM_COMMAND: { - HWND h = (HWND)lParam; - if(h == OkButton && wParam == BN_CLICKED) { - DlgDone = TRUE; - } else if(h == CancelButton && wParam == BN_CLICKED) { - DlgDone = TRUE; - DlgCancel = TRUE; - } - break; - } - - case WM_CLOSE: - case WM_DESTROY: - DlgDone = TRUE; - DlgCancel = TRUE; - break; - - default: - return DefWindowProc(hwnd, msg, wParam, lParam); - } - - return 1; -} -HWND* CreateDialogWindow(LPCTSTR title, int x, int y, int width, int height, int style) -{ - switch (style) { - case STYLE_VERTICAL: - { - if(height < V_DIALOG_HEIGHT) - { - height = V_DIALOG_HEIGHT; - } - ComponentDialog = CreateWindowEx(0, "ComponentDialog", title, - WS_OVERLAPPED | WS_SYSMENU, x, y, width + V_DIALOG_WIDTH, height, NULL, NULL, - NULL, NULL); - SetWindowPos(ComponentDialog, HWND_TOP, x, y, width + V_DIALOG_WIDTH, height, 0); - - OkButton = CreateWindowEx(0, WC_BUTTON, ("OK"), - WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE | BS_DEFPUSHBUTTON, - (width + 13), 10, 70, 23, ComponentDialog, NULL, NULL, NULL); - FontNice(OkButton); - - CancelButton = CreateWindowEx(0, WC_BUTTON, ("Cancel"), - WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE, - (width + 13), 40, 70, 23, ComponentDialog, NULL, NULL, NULL); - FontNice(CancelButton); - - return &ComponentDialog; - } - case STYLE_HORIZONTAL: - { - if(width < H_DIALOG_WIDTH) - { - width = H_DIALOG_WIDTH; - } - ComponentDialog = CreateWindowEx(0, "ComponentDialog", title, - WS_OVERLAPPED | WS_SYSMENU, x, y, width, height + H_DIALOG_HEIGHT, NULL, NULL, - NULL, NULL); - SetWindowPos(ComponentDialog, HWND_TOP, x, y, width, height + H_DIALOG_HEIGHT, 0); - - OkButton = CreateWindowEx(0, WC_BUTTON, ("OK"), - WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE | BS_DEFPUSHBUTTON, - 13, (height + 10), 70, 23, ComponentDialog, NULL, NULL, NULL); - FontNice(OkButton); - - CancelButton = CreateWindowEx(0, WC_BUTTON, ("Cancel"), - WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE, - 96, (height + 10), 70, 23, ComponentDialog, NULL, NULL, NULL); - FontNice(CancelButton); - return &ComponentDialog; - } - default: - return NULL; - } - -} -void ShowDialogWindow() -{ - EnableWindow(*MainWindowHandle, FALSE); - ShowWindow(ComponentDialog, SW_SHOW); -} - -BOOL ProcessDialogWindow() -{ - MSG msg; - DWORD ret; - DlgDone = FALSE; - DlgCancel = FALSE; - while((ret = GetMessage(&msg, NULL, 0, 0)) && !DlgDone) { - if(msg.message == WM_KEYDOWN) { - if(msg.wParam == VK_RETURN) { - DlgDone = TRUE; - break; - } else if(msg.wParam == VK_ESCAPE) { - DlgDone = TRUE; - DlgCancel = TRUE; - break; - } - } - - if(IsDialogMessage(ComponentDialog , &msg)) continue; - TranslateMessage(&msg); - DispatchMessage(&msg); - } - EnableWindow(*MainWindowHandle, TRUE); - /*if(DlgCancel == FALSE) - { - MessageBox(ComponentDialog, - ("Saved"), ("Mouse click"), MB_OK | MB_ICONWARNING); - }*/ - return DlgCancel; -} - -void MakeComponentDialogBoxClass(void) -{ - WNDCLASSEX wc; - memset(&wc, 0, sizeof(wc)); - wc.cbSize = sizeof(wc); - - wc.style = CS_BYTEALIGNCLIENT | CS_BYTEALIGNWINDOW | CS_OWNDC | - CS_DBLCLKS; - wc.lpfnWndProc = (WNDPROC)ComponentDialogProc; - wc.hInstance = *ComponentInstance; - wc.hbrBackground = (HBRUSH)COLOR_BTNSHADOW; - wc.lpszClassName = "ComponentDialog"; - wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.hIcon = (HICON)LoadImage(*ComponentInstance, MAKEINTRESOURCE(4000), //Check This Today - IMAGE_ICON, 32, 32, 0); - wc.hIconSm = (HICON)LoadImage(*ComponentInstance, MAKEINTRESOURCE(4000), - IMAGE_ICON, 16, 16, 0); - - RegisterClassEx(&wc); - - MyNiceFont = CreateFont(16, 0, 0, 0, FW_REGULAR, FALSE, FALSE, FALSE, - ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, - FF_DONTCARE, "Tahoma"); - if(!MyNiceFont) - MyNiceFont = (HFONT)GetStockObject(SYSTEM_FONT); - - MyFixedFont = CreateFont(14, 0, 0, 0, FW_REGULAR, FALSE, FALSE, FALSE, - ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, - FF_DONTCARE, "Lucida Console"); - if(!MyFixedFont) - MyFixedFont = (HFONT)GetStockObject(SYSTEM_FONT); -} - -void InitComponents() -{ - MyNiceFont = CreateFont(16, 0, 0, 0, FW_REGULAR, FALSE, FALSE, FALSE, - ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, - FF_DONTCARE, "Tahoma"); - if(!MyNiceFont) - MyNiceFont = (HFONT)GetStockObject(SYSTEM_FONT); - - MyFixedFont = CreateFont(14, 0, 0, 0, FW_REGULAR, FALSE, FALSE, FALSE, - ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, - FF_DONTCARE, "Lucida Console"); - if(!MyFixedFont) - MyFixedFont = (HFONT)GetStockObject(SYSTEM_FONT); - MakeComponentDialogBoxClass(); -} - -size_t GetNameSize(int Index) -{ - int Pins; - Pins = rgCompData[Index].PinCount; - return sizeof(TCHAR) * Pins * MAX_PIN_NAME; -} - - -void MakeControls(int Index, int Pins) -{ - int i; - HDC hdc = GetDC(ComponentDialog); - SelectObject(hdc, MyNiceFont); - SIZE si; - - int maxLen = 0; - for(i = 0; i < Pins; i++) { - // MessageBox(ComponentDialog, - // rgCompData[Index]->PinNames[i], ("Mouse click"), MB_OK | MB_ICONWARNING); - GetTextExtentPoint32(hdc, rgCompData[Index].PinNames[i], - strlen(rgCompData[Index].PinNames[i]), &si); - if(si.cx > maxLen) maxLen = si.cx; - } - int adj; - if(maxLen > 70) { - adj = maxLen - 70; - } else { - adj = 0; - } - for(i = 0; i < Pins; i++) - { - GetTextExtentPoint32(hdc, rgCompData[Index].PinNames[i], - strlen(rgCompData[Index].PinNames[i]), &si); - - Labels[i] = CreateWindowEx(0, WC_STATIC, rgCompData[Index].PinNames[i], - WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE, - (80 + adj) - si.cx - 4, 13 + i*30, si.cx, 21, - ComponentDialog, NULL, NULL, NULL); - FontNice(Labels[i]); - SendMessage(Textboxes[i], WM_SETTEXT, 0, (LPARAM)rgCompData[Index].PinNames[i]); - - Textboxes[i] = CreateWindowEx(WS_EX_CLIENTEDGE, WC_EDIT, "", - WS_CHILD | ES_AUTOHSCROLL | WS_TABSTOP | WS_CLIPSIBLINGS | - WS_VISIBLE, 80 + adj, 12 + 30*i, 120 - adj, 21, - ComponentDialog, NULL, NULL, NULL); - FontFixed(Textboxes[i]); - } - ReleaseDC(ComponentDialog, hdc); -} -void LoadNameDialog(int Pins, void* Loc) -{ - TCHAR* values = (TCHAR*)Loc; - int i; - for (i = 0; i < Pins; ++i) - { - Edit_SetText(Textboxes[i], (LPSTR)(values + (i * MAX_PIN_NAME))); - } -} - -BOOL SaveNameDialog(int Pins, void* Loc, void* ImageId, int ImageType) -{ - TCHAR* values = (TCHAR*)Loc; - int i; - for (i = 0; i < Pins; ++i) - { - int PinId; - char PinValues[MAX_PIN_NAME]; - if (sizeof(TCHAR) == sizeof(char)) // String is non-unicode - strcpy(PinValues, (char*)(values + (i * MAX_PIN_NAME))); - else // String is unicode - wcstombs(PinValues, (wchar_t*)(values + (i * MAX_PIN_NAME)), MAX_PIN_NAME); - Edit_GetText(Textboxes[i], (LPSTR)(values + (i * MAX_PIN_NAME)), MAX_PIN_NAME); - char NewValue[MAX_PIN_NAME]; - if (sizeof(TCHAR) == sizeof(char)) // String is non-unicode - strcpy(NewValue, (char*)(values + (i * MAX_PIN_NAME))); - else // String is unicode - wcstombs(NewValue, (wchar_t*)(values + (i * MAX_PIN_NAME)), MAX_PIN_NAME); - /*char Debug[256]; - sprintf_s(Debug, "SaveNameDialog: %s %s\n",PinValues, NewValue); - OutputDebugString(Debug);*/ - if (lstrcmp(PinValues, NewValue) != 0) - { - /*sprintf_s(Debug, "Deleting: %s %s\n",PinValues, NewValue); - OutputDebugString(Debug);*/ - PinId = DeletePinImage((LPCTSTR)PinValues, ImageId, i); - // DeleteComponentPin(PinId, ImageId); - } - PinId = RegisterPinName((LPCTSTR)NewValue); - if(PinId) - { - PinIds[i] = PinId; - } - SetPinImage(PinId, ImageId, ImageType, i); - // if(PinId) - // { - // AddComponentPin(PinId, ImageId); - // } - } - return TRUE; -} -void ShowNameDialog(int Index, void* PinName, void* ImageId) -{ - HWND *NameDialog; - BOOL Canceled, Complete = FALSE; - int w, h, Pins; - Pins = rgCompData[Index].PinCount; - // char vx[3],vy[3]; - // _itoa(Pins,vy,10); - // _itoa(x,vx,10); - // MessageBox(AdvancedDialog, _(vx), _(vy), MB_OK | MB_ICONWARNING); - // MessageBox(ComponentDialog, - // (vy), ("Mouse click"), MB_OK | MB_ICONWARNING); - // if(Pins >MAX_PIN_COUNT) oops(); - w = 304 - V_DIALOG_WIDTH; - h = 15 + 30 * (Pins + 1); - PinIds = (int*)AllocImageHeap(sizeof(int)*Pins); - NameDialog = CreateDialogWindow("Pin Naming", 100, 100, w, h, STYLE_VERTICAL); - MakeControls(Index, Pins); - LoadNameDialog(Pins, PinName); - ShowDialogWindow(); - SetFocus(Textboxes[0]); - SendMessage(Textboxes[0], EM_SETSEL, 0, -1); - Canceled = ProcessDialogWindow(); - while(Canceled == FALSE) - { - Complete = SaveNameDialog(Pins, PinName, ImageId, rgCompData[Index].ComponentId); - if(Complete == TRUE) - { - // MessageBox(*SwitchDialog, - // ("Saved"), ("Mouse click"), MB_OK | MB_ICONWARNING); - break; - }else - { - Complete =TRUE; - Canceled = ProcessDialogWindow(); - } - } - DestroyWindow(*NameDialog); -} - -double VoltRequest(int PinId, void* ComponentAddress) -{ - return GetGlobalVoltage(PinId,ComponentAddress); -} - -// double GlobalVoltChange(int PinId, void *ComponentAddress, double volt) -// { -// return RequestVoltChange(PinId,ComponentAddress,volt); -// } - -double VoltChange(int PinId, int Index, void* ComponentAddress, double Volt) -{ - return RequestVoltChange(PinId, Index, ComponentAddress, Volt); -}
\ No newline at end of file diff --git a/ldmicro/components/dpdt.cpp b/ldmicro/components/dpdt.cpp deleted file mode 100644 index c04c901..0000000 --- a/ldmicro/components/dpdt.cpp +++ /dev/null @@ -1,539 +0,0 @@ -/* DPDT component file -* Code version: 2.0 -* Version description: Adds latching functionality to component -* Version steability: -* GUI -> Stable -* Functionality -> No known bugs. -* Bugs: -* 1. - -* -*/ - -///Includes -#include <wincodec.h> -#include <stdio.h> -//#include <string.h> -#include <commctrl.h> -#include <Windowsx.h> - -#include "componentstructs.h" -#include "componentfunctions.h" -#include "componentimages.h" -#include "components.h" - -///Window handles -static HWND DPDTState1; -static HWND DPDTState2; -static HWND ModeLatchedDPDT; -static HWND ModeTempDPDT; -HWND* SettingsDialogDPDT; - -///Global variables -enum DPDT_Pins { in1 = 0, in2, out11, out12, out21, out22 }; - -///Function definitions -int InitDpdt(void * ComponentAddress) -{ - DpdtStruct* d = (DpdtStruct*)ComponentAddress; - d->image = DPDT_1; - d->NS1 = TRUE; - d->latched = TRUE; - d->Volt[in1] = V_OPEN; - d->Volt[in2] = V_OPEN; - d->Volt[out11] = V_OPEN; - d->Volt[out12] = V_OPEN; - d->Volt[out21] = V_OPEN; - d->Volt[out22] = V_OPEN; - - return DPDT_1; -} - -void SetDpdtIds(int* id, void* ComponentAddress) -{ - DpdtStruct* d = (DpdtStruct*)ComponentAddress; - d->PinId[in1] = *id++; - d->PinId[in2] = *id++; - d->PinId[out11] = *id++; - d->PinId[out12] = *id++; - d->PinId[out21] = *id++; - d->PinId[out22] = *id++; -} - -void MakeSettingsDialogDPDT() -{ - ///Switch action mode - HWND InitLatched = CreateWindowEx(0, WC_BUTTON, ("Action mode"), - WS_CHILD | BS_GROUPBOX | WS_VISIBLE | WS_TABSTOP, - 7, 3, 120, 65, *SettingsDialogDPDT, NULL, NULL, NULL); - FontNice(InitLatched); - - ModeLatchedDPDT = CreateWindowEx(0, WC_BUTTON, ("Latched"), - WS_CHILD | BS_AUTORADIOBUTTON | WS_TABSTOP | WS_VISIBLE | WS_GROUP, - 16, 21, 100, 20, *SettingsDialogDPDT, NULL, NULL, NULL); - FontNice(ModeLatchedDPDT); - - ModeTempDPDT = CreateWindowEx(0, WC_BUTTON, ("Temporary"), - WS_CHILD | BS_AUTORADIOBUTTON | WS_TABSTOP | WS_VISIBLE, - 16, 41, 100, 20, *SettingsDialogDPDT, NULL, NULL, NULL); - FontNice(ModeTempDPDT); - - ///Switch initial status - HWND InitOut = CreateWindowEx(0, WC_BUTTON, ("Initial output state"), - WS_CHILD | BS_GROUPBOX | WS_VISIBLE | WS_TABSTOP, - 140, 3, 120, 65, *SettingsDialogDPDT, NULL, NULL, NULL); - FontNice(InitOut); - - DPDTState1 = CreateWindowEx(0, WC_BUTTON, ("State 1"), - WS_CHILD | BS_AUTORADIOBUTTON | WS_TABSTOP | WS_VISIBLE | WS_GROUP, - 149, 21, 100, 20, *SettingsDialogDPDT, NULL, NULL, NULL); - FontNice(DPDTState1); - - DPDTState2 = CreateWindowEx(0, WC_BUTTON, ("State 2"), - WS_CHILD | BS_AUTORADIOBUTTON | WS_TABSTOP | WS_VISIBLE, - 149, 41, 100, 20, *SettingsDialogDPDT, NULL, NULL, NULL); - FontNice(DPDTState2); -} - -void LoadSettings(DpdtStruct* d) -{ - if (d->latched) - Button_SetCheck(ModeLatchedDPDT, BST_CHECKED); - else - Button_SetCheck(ModeTempDPDT, BST_CHECKED); - if (d->NS1) - Button_SetCheck(DPDTState1, BST_CHECKED); - else - Button_SetCheck(DPDTState2, BST_CHECKED); -} - -BOOL SaveSettings(DpdtStruct* d, void* ImageLocation) -{ - if (Button_GetState(ModeLatchedDPDT) == BST_CHECKED) - d->latched = TRUE; - else - d->latched = FALSE; - - if (Button_GetState(DPDTState1) == BST_CHECKED) - d->NS1 = TRUE; - else if (Button_GetState(DPDTState2) == BST_CHECKED) - d->NS1 = FALSE; - else - { - MessageBox(*SettingsDialogDPDT, - ("Incomplete"), ("Warning"), MB_OK | MB_ICONWARNING); - return FALSE; - } - - if (d->NS1) - d->image = DPDT_1; - else - d->image = DPDT_2; - - SetImage(d->image, ImageLocation); - RefreshImages(); - - return TRUE; -} - -void DpdtSettingsDialog(void* ComponentAddress, void* ImageLocation) -{ - DpdtStruct* d = (DpdtStruct*)ComponentAddress; - BOOL exitStatus; - - //Create dialog window instance - SettingsDialogDPDT = CreateDialogWindow("SPDT Settings Dialog", 100, 100, 263, 145, STYLE_VERTICAL); - - //Make the settings dialog - MakeSettingsDialogDPDT(); - - //Load settings - LoadSettings(d); - - //Show dialog window - ShowDialogWindow(); - - exitStatus = ProcessDialogWindow(); - while (exitStatus == FALSE) - { - exitStatus = SaveSettings(d, ImageLocation); - if (exitStatus == TRUE) - break; - else - { - exitStatus = TRUE; - exitStatus = ProcessDialogWindow(); - } - } - - DestroyWindow(*SettingsDialogDPDT); -} - -//Dynamically check and equalise the voltage on all pins that are connected to DPST at runtime -double EqualiseRuntimeVoltageDPDT(void* ComponentAdderss, int index, double volt) -{ - DpdtStruct* d = (DpdtStruct*)ComponentAdderss; - - ///Check if DPDT switch is in state 1; i.e Input 1 is connected to output11, Input 2 is connected to output21 - if (d->NS1) - { - ///If DPDT switch is in state 1 then output12 and output22 will be floating/open - if (index == out12) - { - d->Volt[out12] = V_OPEN; - d->Volt[out22] = VoltChange(d->PinId[out22], out22, ComponentAdderss, V_OPEN); - } - else if (index == out22) - { - d->Volt[out12] = VoltChange(d->PinId[out12], out12, ComponentAdderss, V_OPEN); - d->Volt[out22] = V_OPEN; - } - else - { - d->Volt[out12] = VoltChange(d->PinId[out12], out12, ComponentAdderss, V_OPEN); - d->Volt[out22] = VoltChange(d->PinId[out22], out22, ComponentAdderss, V_OPEN); - } - - double Vin; - double Vout; - - ///Get voltages at the connected pins - if (index == in1) - { - Vin = volt; - Vout = VoltRequest(d->PinId[out11], ComponentAdderss); - } - else if (index == out11) - { - Vin = VoltRequest(d->PinId[in1], ComponentAdderss); - Vout = volt; - } - else - { - Vin = VoltRequest(d->PinId[in1], ComponentAdderss); - Vout = VoltRequest(d->PinId[out11], ComponentAdderss); - } - - ///Set 1: input 1, output11, output12 - ///If either pin is grounded then all pins are set to GND - if (Vin == GND || Vout == GND) - { - d->Volt[out11] = VoltChange(d->PinId[out11], out11, ComponentAdderss, GND); - d->Volt[in1] = VoltChange(d->PinId[in1], in1, ComponentAdderss, GND); - } - ///If Vin is set as open - else if (Vin == V_OPEN) - d->Volt[in1] = VoltChange(d->PinId[in1], in1, ComponentAdderss, Vout); - ///If Vout is set as open - else if (Vout == V_OPEN) - d->Volt[out11] = VoltChange(d->PinId[out11], out11, ComponentAdderss, Vin); - ///If no pin is grounded then all pins are set to the max voltage of the pins - else - { - d->Volt[out11] = VoltChange(d->PinId[out11], out11, ComponentAdderss, max(Vin, Vout)); - d->Volt[in1] = VoltChange(d->PinId[in1], in1, ComponentAdderss, max(Vin, Vout)); - } - - ///Get voltages at the connected pins - if (index == in2) - { - Vin = volt; - Vout = VoltRequest(d->PinId[out21], ComponentAdderss); - } - else if (index == out21) - { - Vin = VoltRequest(d->PinId[in2], ComponentAdderss); - Vout = volt; - } - else - { - Vin = VoltRequest(d->PinId[in2], ComponentAdderss); - Vout = VoltRequest(d->PinId[out21], ComponentAdderss); - } - - ///Set 2: input 2, output21, output22 - ///If either pin is grounded then all pins are set to GND - if (Vin == GND || Vout == GND) - { - d->Volt[out21] = VoltChange(d->PinId[out21], out21, ComponentAdderss, GND); - d->Volt[in2] = VoltChange(d->PinId[in2], in2, ComponentAdderss, GND); - } - ///If Vin is set as open - else if (Vin == V_OPEN) - d->Volt[in2] = VoltChange(d->PinId[in2], in2, ComponentAdderss, Vout); - ///If Vout is set as open - else if (Vout == V_OPEN) - d->Volt[out21] = VoltChange(d->PinId[out21], out21, ComponentAdderss, Vin); - ///If no pin is grounded then all pins are set to the max voltage of the pins - else - { - d->Volt[out21] = VoltChange(d->PinId[out21], out21, ComponentAdderss, max(Vin, Vout)); - d->Volt[in2] = VoltChange(d->PinId[in2], in2, ComponentAdderss, max(Vin, Vout)); - } - } - ///Check if DPDT switch is in state 2; i.e Input 1 is connected to output12, Input 2 is connected to output22 - else - { - ///If DPDT switch is in state 2 then output11 and output21 will be floating/open - if (index == out11) - { - d->Volt[out11] = V_OPEN; - d->Volt[out21] = VoltChange(d->PinId[out21], out21, ComponentAdderss, V_OPEN); - } - else if (index == out21) - { - d->Volt[out11] = VoltChange(d->PinId[out11], out11, ComponentAdderss, V_OPEN); - d->Volt[out21] = V_OPEN; - } - else - { - d->Volt[out11] = VoltChange(d->PinId[out11], out11, ComponentAdderss, V_OPEN); - d->Volt[out21] = VoltChange(d->PinId[out21], out21, ComponentAdderss, V_OPEN); - } - - double Vin; - double Vout; - - ///Get voltages at the connected pins - if (index == in1) - { - Vin = volt; - Vout = VoltRequest(d->PinId[out12], ComponentAdderss); - } - else if (index == out12) - { - Vin = VoltRequest(d->PinId[in1], ComponentAdderss); - Vout = volt; - } - else - { - Vin = VoltRequest(d->PinId[in1], ComponentAdderss); - Vout = VoltRequest(d->PinId[out12], ComponentAdderss); - } - - ///Set 1: input 1, output11, output12 - ///If either pin is grounded then all pins are set to GND - if (Vin == GND || Vout == GND) - { - d->Volt[out12] = VoltChange(d->PinId[out12], out12, ComponentAdderss, GND); - d->Volt[in1] = VoltChange(d->PinId[in1], in1, ComponentAdderss, GND); - } - ///If Vin is set as open - else if (Vin == V_OPEN) - d->Volt[in1] = VoltChange(d->PinId[in1], in1, ComponentAdderss, Vout); - ///If Vout is set as open - else if (Vout == V_OPEN) - d->Volt[out12] = VoltChange(d->PinId[out12], out12, ComponentAdderss, Vin); - ///If no pin is grounded then all pins are set to the max voltage of the pins - else - { - d->Volt[out12] = VoltChange(d->PinId[out12], out12, ComponentAdderss, max(Vin, Vout)); - d->Volt[in1] = VoltChange(d->PinId[in1], in1, ComponentAdderss, max(Vin, Vout)); - } - - ///Get voltages at the connected pins - if (index == in2) - { - Vin = volt; - Vout = VoltRequest(d->PinId[out22], ComponentAdderss); - } - else if (index == out22) - { - Vin = VoltRequest(d->PinId[in2], ComponentAdderss); - Vout = volt; - } - else - { - Vin = VoltRequest(d->PinId[in2], ComponentAdderss); - Vout = VoltRequest(d->PinId[out22], ComponentAdderss); - } - - ///Set 2: input 2, output21, output22 - ///If either pin is grounded then all pins are set to GND - if (Vin == GND || Vout == GND) - { - d->Volt[out22] = VoltChange(d->PinId[out22], out22, ComponentAdderss, GND); - d->Volt[in2] = VoltChange(d->PinId[in2], in2, ComponentAdderss, GND); - } - ///If Vin is set as open - else if (Vin == V_OPEN) - d->Volt[in2] = VoltChange(d->PinId[in2], in2, ComponentAdderss, Vout); - ///If Vout is set as open - else if (Vout == V_OPEN) - d->Volt[out22] = VoltChange(d->PinId[out22], out22, ComponentAdderss, Vin); - ///If no pin is grounded then all pins are set to the max voltage of the pins - else - { - d->Volt[out22] = VoltChange(d->PinId[out22], out22, ComponentAdderss, max(Vin, Vout)); - d->Volt[in2] = VoltChange(d->PinId[in2], in2, ComponentAdderss, max(Vin, Vout)); - } - } - - return d->Volt[index]; -} - -//Perform a static check and equalise the voltage on all pins that are connected to DPST at runtime -void EqualiseStaticVoltageDPDT(void* ComponentAdderss) -{ - DpdtStruct* d = (DpdtStruct*)ComponentAdderss; - - ///Check if DPDT switch is in state 1; i.e Input 1 is connected to output11, Input 2 is connected to output21 - if (d->NS1) - { - ///If DPDT switch is in state 1 then output12 and output22 will be floating/open - d->Volt[out12] = VoltChange(d->PinId[out12], out12, ComponentAdderss, V_OPEN); - d->Volt[out22] = VoltChange(d->PinId[out22], out22, ComponentAdderss, V_OPEN); - - ///Get voltages at the connected pins - double Vin = VoltRequest(d->PinId[in1], ComponentAdderss); - double Vout = VoltRequest(d->PinId[out11], ComponentAdderss); - - ///Set 1: input 1, output11, output12 - ///If either pin is grounded then all pins are set to GND - if (Vin == GND || Vout == GND) - { - d->Volt[out11] = VoltChange(d->PinId[out11], out11, ComponentAdderss, GND); - d->Volt[in1] = VoltChange(d->PinId[in1], in1, ComponentAdderss, GND); - } - ///If Vin is set as open - else if (Vin == V_OPEN) - d->Volt[in1] = VoltChange(d->PinId[in1], in1, ComponentAdderss, Vout); - ///If Vout is set as open - else if (Vout == V_OPEN) - d->Volt[out11] = VoltChange(d->PinId[out11], out11, ComponentAdderss, Vin); - ///If no pin is grounded then all pins are set to the max voltage of the pins - else - { - d->Volt[out11] = VoltChange(d->PinId[out11], out11, ComponentAdderss, max(Vin, Vout)); - d->Volt[in1] = VoltChange(d->PinId[in1], in1, ComponentAdderss, max(Vin, Vout)); - } - - Vin = VoltRequest(d->PinId[in2], ComponentAdderss); - Vout = VoltRequest(d->PinId[out21], ComponentAdderss); - ///Set 2: input 2, output21, output22 - ///If either pin is grounded then all pins are set to GND - if (Vin == GND || Vout == GND) - { - d->Volt[out21] = VoltChange(d->PinId[out21], out21, ComponentAdderss, GND); - d->Volt[in2] = VoltChange(d->PinId[in2], in2, ComponentAdderss, GND); - } - ///If Vin is set as open - else if (Vin == V_OPEN) - d->Volt[in2] = VoltChange(d->PinId[in2], in2, ComponentAdderss, Vout); - ///If Vout is set as open - else if (Vout == V_OPEN) - d->Volt[out21] = VoltChange(d->PinId[out21], out21, ComponentAdderss, Vin); - ///If no pin is grounded then all pins are set to the max voltage of the pins - else - { - d->Volt[out21] = VoltChange(d->PinId[out21], out21, ComponentAdderss, max(Vin, Vout)); - d->Volt[in2] = VoltChange(d->PinId[in2], in2, ComponentAdderss, max(Vin, Vout)); - } - } - ///Check if DPDT switch is in state 2; i.e Input 1 is connected to output12, Input 2 is connected to output22 - else - { - ///If DPDT switch is in state 2 then output11 and output21 will be floating/open - d->Volt[out11] = VoltChange(d->PinId[out11], out11, ComponentAdderss, V_OPEN); - d->Volt[out21] = VoltChange(d->PinId[out21], out21, ComponentAdderss, V_OPEN); - - ///Get voltages at the connected pins - double Vin = VoltRequest(d->PinId[in1], ComponentAdderss); - double Vout = VoltRequest(d->PinId[out12], ComponentAdderss); - - ///Set 1: input 1, output11, output12 - ///If either pin is grounded then all pins are set to GND - if (Vin == GND || Vout == GND) - { - d->Volt[out12] = VoltChange(d->PinId[out12], out12, ComponentAdderss, GND); - d->Volt[in1] = VoltChange(d->PinId[in1], in1, ComponentAdderss, GND); - } - ///If Vin is set as open - else if (Vin == V_OPEN) - d->Volt[in1] = VoltChange(d->PinId[in1], in1, ComponentAdderss, Vout); - ///If Vout is set as open - else if (Vout == V_OPEN) - d->Volt[out12] = VoltChange(d->PinId[out12], out12, ComponentAdderss, Vin); - ///If no pin is grounded then all pins are set to the max voltage of the pins - else - { - d->Volt[out12] = VoltChange(d->PinId[out12], out12, ComponentAdderss, max(Vin, Vout)); - d->Volt[in1] = VoltChange(d->PinId[in1], in1, ComponentAdderss, max(Vin, Vout)); - } - - Vin = VoltRequest(d->PinId[in2], ComponentAdderss); - Vout = VoltRequest(d->PinId[out22], ComponentAdderss); - ///Set 2: input 2, output21, output22 - ///If either pin is grounded then all pins are set to GND - if (Vin == GND || Vout == GND) - { - d->Volt[out22] = VoltChange(d->PinId[out22], out22, ComponentAdderss, GND); - d->Volt[in2] = VoltChange(d->PinId[in2], in2, ComponentAdderss, GND); - } - ///If Vin is set as open - else if (Vin == V_OPEN) - d->Volt[in2] = VoltChange(d->PinId[in2], in2, ComponentAdderss, Vout); - ///If Vout is set as open - else if (Vout == V_OPEN) - d->Volt[out22] = VoltChange(d->PinId[out22], out22, ComponentAdderss, Vin); - ///If no pin is grounded then all pins are set to the max voltage of the pins - else - { - d->Volt[out22] = VoltChange(d->PinId[out22], out22, ComponentAdderss, max(Vin, Vout)); - d->Volt[in2] = VoltChange(d->PinId[in2], in2, ComponentAdderss, max(Vin, Vout)); - } - } -} - -void ToggleState(DpdtStruct* d, void* ImageLocation) -{ - d->image = (d->image == DPDT_1) ? DPDT_2 : DPDT_1; - d->NS1 = (d->NS1 == TRUE) ? FALSE : TRUE; - SetImage(d->image, ImageLocation); - RefreshImages(); -} - -void HandleDpdtEvent(void * ComponentAddress, int Event, BOOL SimulationStarted, void * ImageLocation, UINT ImageId, HWND * h) -{ - - DpdtStruct* d = (DpdtStruct*)ComponentAddress; - - if (SimulationStarted) - { - switch (Event) - { - case EVENT_MOUSE_DOWN: - ToggleState(d, ImageLocation); - EqualiseStaticVoltageDPDT(ComponentAddress); - break; - case EVENT_MOUSE_UP: - if (!d->latched) - { - ToggleState(d, ImageLocation); - EqualiseStaticVoltageDPDT(ComponentAddress); - } - break; - default: - break; - } - } - else - { - switch (Event) - { - case EVENT_MOUSE_DBLCLICK: - DpdtSettingsDialog(ComponentAddress, ImageLocation); - break; - default: - break; - } - } -} - -double DpdtVoltChanged(void * ComponentAddress, BOOL SimulationStarted, int index, double Volt, int Source, void * ImageLocation) -{ - - if (SimulationStarted) - return EqualiseRuntimeVoltageDPDT(ComponentAddress, index, Volt); - - return Volt; -}
\ No newline at end of file diff --git a/ldmicro/components/dpst.cpp b/ldmicro/components/dpst.cpp deleted file mode 100644 index d806dbb..0000000 --- a/ldmicro/components/dpst.cpp +++ /dev/null @@ -1,417 +0,0 @@ -/* DPST component file -* Code version: 2.1 -* Version description: Fixes minor bugs in v2.0 -* Version steability: -* GUI -> Stable -* Functionality -> Bugs found. -* Bugs: -* 1. Voltages dont load properly during simulation when the "Switch" component controls input pin of the DPST component. -* -*/ - -///Includes -#include <wincodec.h> -#include <stdio.h> -//#include <string.h> -#include <commctrl.h> -#include <Windowsx.h> - -#include "componentstructs.h" -#include "componentfunctions.h" -#include "componentimages.h" -#include "components.h" - -///Window handles -static HWND State1; -static HWND State2; -static HWND ModeLatchedDPST; -static HWND ModeTempDPST; -HWND* SettingsDialogDPST; - -///Global variables -enum DPST_Pins { in1 = 0, in2, out1, out2 }; - -///Function definitions -int InitDpst(void * ComponentAddress) -{ - DpstStruct* d = (DpstStruct*)ComponentAddress; - d->image = DPST_1; - d->NO = FALSE; - d->latched = TRUE; - d->Volt[in1] = V_OPEN; - d->Volt[in2] = V_OPEN; - d->Volt[out1] = V_OPEN; - d->Volt[out2] = V_OPEN; - - return DPST_1; -} - -void SetDpstIds(int* id, void* ComponentAddress) -{ - DpstStruct* d = (DpstStruct*)ComponentAddress; - d->PinId[in1] = *id++; - d->PinId[in2] = *id++; - d->PinId[out1] = *id++; - d->PinId[out2] = *id++; -} - -void MakeSettingsDialogDPST() -{ - ///Switch action mode - HWND InitLatched = CreateWindowEx(0, WC_BUTTON, ("Action mode"), - WS_CHILD | BS_GROUPBOX | WS_VISIBLE | WS_TABSTOP, - 7, 3, 120, 65, *SettingsDialogDPST, NULL, NULL, NULL); - FontNice(InitLatched); - - ModeLatchedDPST = CreateWindowEx(0, WC_BUTTON, ("Latched"), - WS_CHILD | BS_AUTORADIOBUTTON | WS_TABSTOP | WS_VISIBLE | WS_GROUP, - 16, 21, 100, 20, *SettingsDialogDPST, NULL, NULL, NULL); - FontNice(ModeLatchedDPST); - - ModeTempDPST = CreateWindowEx(0, WC_BUTTON, ("Temporary"), - WS_CHILD | BS_AUTORADIOBUTTON | WS_TABSTOP | WS_VISIBLE, - 16, 41, 100, 20, *SettingsDialogDPST, NULL, NULL, NULL); - FontNice(ModeTempDPST); - - ///Switch initial status - HWND InitOut = CreateWindowEx(0, WC_BUTTON, ("Initial output state"), - WS_CHILD | BS_GROUPBOX | WS_VISIBLE | WS_TABSTOP, - 140, 3, 120, 65, *SettingsDialogDPST, NULL, NULL, NULL); - FontNice(InitOut); - - State1 = CreateWindowEx(0, WC_BUTTON, ("State 1"), - WS_CHILD | BS_AUTORADIOBUTTON | WS_TABSTOP | WS_VISIBLE | WS_GROUP, - 149, 21, 100, 20, *SettingsDialogDPST, NULL, NULL, NULL); - FontNice(State1); - - State2 = CreateWindowEx(0, WC_BUTTON, ("State 2"), - WS_CHILD | BS_AUTORADIOBUTTON | WS_TABSTOP | WS_VISIBLE, - 149, 41, 100, 20, *SettingsDialogDPST, NULL, NULL, NULL); - FontNice(State2); -} - -void LoadSettings(DpstStruct* d) -{ - - if (d->latched) - Button_SetCheck(ModeLatchedDPST, BST_CHECKED); - else - Button_SetCheck(ModeTempDPST, BST_CHECKED); - - if (!d->NO) - Button_SetCheck(State1, BST_CHECKED); - else - Button_SetCheck(State2, BST_CHECKED); -} - -BOOL SaveSettings(DpstStruct* d, void* ImageLocation) -{ - if (Button_GetState(ModeLatchedDPST) == BST_CHECKED) - d->latched = TRUE; - else if (Button_GetState(ModeTempDPST) == BST_CHECKED) - d->latched = FALSE; - else - { - MessageBox(*SettingsDialogDPST, - ("Incomplete"), ("Warning"), MB_OK | MB_ICONWARNING); - return FALSE; - } - - if (Button_GetState(State1) == BST_CHECKED) - d->NO = FALSE; - else if (Button_GetState(State2) == BST_CHECKED) - d->NO = TRUE; - else - { - MessageBox(*SettingsDialogDPST, - ("Incomplete"), ("Warning"), MB_OK | MB_ICONWARNING); - return FALSE; - } - - if (!d->NO) - d->image = DPST_1; - else - d->image = DPST_2; - - SetImage(d->image, ImageLocation); - RefreshImages(); - - return TRUE; -} - -void DpstSettingsDialog(void* ComponentAddress, void* ImageLocation) -{ - DpstStruct* d = (DpstStruct*)ComponentAddress; - BOOL exitStatus; - - //Create dialog window instance - SettingsDialogDPST = CreateDialogWindow("SPDT Settings Dialog", 100, 100, 263, 145, STYLE_VERTICAL); - - //Make the settings dialog - MakeSettingsDialogDPST(); - - //Load settings - LoadSettings(d); - - //Show dialog window - ShowDialogWindow(); - - exitStatus = ProcessDialogWindow(); - while (exitStatus == FALSE) - { - exitStatus = SaveSettings(d, ImageLocation); - if (exitStatus == TRUE) - break; - else - { - exitStatus = TRUE; - exitStatus = ProcessDialogWindow(); - } - } - - DestroyWindow(*SettingsDialogDPST); -} - -//Dynamically check and equalise the voltage on all pins that are connected to DPST at runtime -double EqualiseRuntimeVoltageDPST(void* ComponentAdderss, int index, double volt) -{ - DpstStruct* d = (DpstStruct*)ComponentAdderss; - - ///Check if the switch is open - if (d->NO) - { - ///If switch is open then all terminals will be floating/open - switch (index) - { - case in1: - d->Volt[in1] = V_OPEN; - d->Volt[in2] = VoltChange(d->PinId[in2], in2, ComponentAdderss, V_OPEN); - d->Volt[out1] = VoltChange(d->PinId[out1], out1, ComponentAdderss, V_OPEN); - d->Volt[out2] = VoltChange(d->PinId[out2], out2, ComponentAdderss, V_OPEN); - break; - case in2: - d->Volt[in1] = VoltChange(d->PinId[in1], in1, ComponentAdderss, V_OPEN); - d->Volt[in2] = V_OPEN; - d->Volt[out1] = VoltChange(d->PinId[out1], out1, ComponentAdderss, V_OPEN); - d->Volt[out2] = VoltChange(d->PinId[out2], out2, ComponentAdderss, V_OPEN); - case out1: - d->Volt[in1] = VoltChange(d->PinId[in1], in1, ComponentAdderss, V_OPEN); - d->Volt[in2] = VoltChange(d->PinId[in2], in2, ComponentAdderss, V_OPEN); - d->Volt[out1] = V_OPEN; - d->Volt[out2] = VoltChange(d->PinId[out2], out2, ComponentAdderss, V_OPEN); - break; - case out2: - d->Volt[in1] = VoltChange(d->PinId[in1], in1, ComponentAdderss, V_OPEN); - d->Volt[in2] = VoltChange(d->PinId[in2], in2, ComponentAdderss, V_OPEN); - d->Volt[out1] = VoltChange(d->PinId[out1], out1, ComponentAdderss, V_OPEN); - d->Volt[out2] = V_OPEN; - break; - default: - d->Volt[in1] = VoltChange(d->PinId[in1], in1, ComponentAdderss, V_OPEN); - d->Volt[in2] = VoltChange(d->PinId[in2], in2, ComponentAdderss, V_OPEN); - d->Volt[out1] = VoltChange(d->PinId[out1], out1, ComponentAdderss, V_OPEN); - d->Volt[out2] = VoltChange(d->PinId[out2], out2, ComponentAdderss, V_OPEN); - break; - } - } - ///If the switch is connected - else - { - double Vin; - double Vout; - - ///Get voltages at the connected pins - if (index == in1) - { - Vin = volt; - Vout = VoltRequest(d->PinId[out1], ComponentAdderss); - } - else if (index == out1) - { - Vin = VoltRequest(d->PinId[in1], ComponentAdderss); - Vout = volt; - } - else - { - Vin = VoltRequest(d->PinId[in1], ComponentAdderss); - Vout = VoltRequest(d->PinId[out1], ComponentAdderss); - } - - ///Equalise voltage for input 1 output 1 pair - ///If either pin is grounded then all pins are set to GND (Static event) - if (Vin == GND || Vout == GND) - { - d->Volt[out1] = VoltChange(d->PinId[out1], out1, ComponentAdderss, GND); - d->Volt[in1] = VoltChange(d->PinId[in1], in1, ComponentAdderss, GND); - } - ///If Vin is set as open - else if (Vin == V_OPEN) - d->Volt[in1] = VoltChange(d->PinId[in1], in1, ComponentAdderss, Vout); - ///If Vout is set as open - else if (Vout == V_OPEN) - d->Volt[out1] = VoltChange(d->PinId[out1], out1, ComponentAdderss, Vin); - ///If no pin is grounded then all pins are set to the max voltage of the pins (Dynamic event) - else - { - d->Volt[out1] = VoltChange(d->PinId[out1], out1, ComponentAdderss, max(Vin, Vout)); - d->Volt[in1] = VoltChange(d->PinId[in1], in1, ComponentAdderss, max(Vin, Vout)); - } - - ///Get voltages at the connected pins - if (index == in2) - { - Vin = volt; - Vout = VoltRequest(d->PinId[out2], ComponentAdderss); - } - else if (index == out2) - { - Vin = VoltRequest(d->PinId[in2], ComponentAdderss); - Vout = volt; - } - else - { - Vin = VoltRequest(d->PinId[in2], ComponentAdderss); - Vout = VoltRequest(d->PinId[out2], ComponentAdderss); - } - - ///Equalise voltage for input 2 output 2 pair - ///If either pin is grounded then all pins are set to GND (Static event) - if (Vin == GND || Vout == GND) - { - d->Volt[out2] = VoltChange(d->PinId[out2], out2, ComponentAdderss, GND); - d->Volt[in2] = VoltChange(d->PinId[in2], in2, ComponentAdderss, GND); - } - ///If Vin is set as open - else if (Vin == V_OPEN) - d->Volt[in2] = VoltChange(d->PinId[in2], in2, ComponentAdderss, Vout); - ///If Vout is set as open - else if (Vout == V_OPEN) - d->Volt[out2] = VoltChange(d->PinId[out2], out2, ComponentAdderss, Vin); - ///If no pin is grounded then all pins are set to the max voltage of the pins (Dynamic event) - else - { - d->Volt[out2] = VoltChange(d->PinId[out2], out2, ComponentAdderss, max(Vin, Vout)); - d->Volt[in2] = VoltChange(d->PinId[in2], in2, ComponentAdderss, max(Vin, Vout)); - } - } - - return d->Volt[index]; -} - -//Perform a static check and equalise the voltage on all pins that are connected to DPST at runtime -void EqualiseStaticVoltageDPST(void* ComponentAdderss) -{ - DpstStruct* d = (DpstStruct*)ComponentAdderss; - - ///Check if the switch is open - if (d->NO) - { - ///If switch is open then all terminals will be floating/open - d->Volt[in1] = VoltChange(d->PinId[in1], in1, ComponentAdderss, V_OPEN); - d->Volt[in2] = VoltChange(d->PinId[in2], in2, ComponentAdderss, V_OPEN); - d->Volt[out1] = VoltChange(d->PinId[out1], out1, ComponentAdderss, V_OPEN); - d->Volt[out2] = VoltChange(d->PinId[out2], out2, ComponentAdderss, V_OPEN); - - } - ///If the switch is connected - else - { - double Vin = VoltRequest(d->PinId[in1], ComponentAdderss); - double Vout = VoltRequest(d->PinId[out1], ComponentAdderss); - - ///Equalise voltage for input 1 output 1 pair - ///If either pin is grounded then all pins are set to GND (Static event) - if (Vin == GND || Vout == GND) - { - d->Volt[out1] = VoltChange(d->PinId[out1], out1, ComponentAdderss, GND); - d->Volt[in1] = VoltChange(d->PinId[in1], in1, ComponentAdderss, GND); - } - ///If Vin is set as open - else if (Vin == V_OPEN) - d->Volt[in1] = VoltChange(d->PinId[in1], in1, ComponentAdderss, Vout); - ///If Vout is set as open - else if (Vout == V_OPEN) - d->Volt[out1] = VoltChange(d->PinId[out1], out1, ComponentAdderss, Vin); - ///If no pin is grounded then all pins are set to the max voltage of the pins (Dynamic event) - else - { - d->Volt[out1] = VoltChange(d->PinId[out1], out1, ComponentAdderss, max(Vin, Vout)); - d->Volt[in1] = VoltChange(d->PinId[in1], in1, ComponentAdderss, max(Vin, Vout)); - } - - Vin = VoltRequest(d->PinId[in2], ComponentAdderss); - Vout = VoltRequest(d->PinId[out2], ComponentAdderss); - - ///Equalise voltage for input 2 output 2 pair - ///If either pin is grounded then all pins are set to GND (Static event) - if (Vin == GND || Vout == GND) - { - d->Volt[out2] = VoltChange(d->PinId[out2], out2, ComponentAdderss, GND); - d->Volt[in2] = VoltChange(d->PinId[in2], in2, ComponentAdderss, GND); - } - ///If Vin is set as open - else if (Vin == V_OPEN) - d->Volt[in2] = VoltChange(d->PinId[in2], in2, ComponentAdderss, Vout); - ///If Vout is set as open - else if (Vout == V_OPEN) - d->Volt[out2] = VoltChange(d->PinId[out2], out2, ComponentAdderss, Vin); - ///If no pin is grounded then all pins are set to the max voltage of the pins (Dynamic event) - else - { - d->Volt[out2] = VoltChange(d->PinId[out2], out2, ComponentAdderss, max(Vin, Vout)); - d->Volt[in2] = VoltChange(d->PinId[in2], in2, ComponentAdderss, max(Vin, Vout)); - } - } -} - -void ToggleState(DpstStruct* d, void* ImageLocation) -{ - d->image = (d->image == DPST_1) ? DPST_2 : DPST_1; - d->NO = (d->NO == TRUE) ? FALSE : TRUE; - SetImage(d->image, ImageLocation); - RefreshImages(); -} - -void HandleDpstEvent(void * ComponentAddress, int Event, BOOL SimulationStarted, void * ImageLocation, UINT ImageId, HWND * h) -{ - DpstStruct* d = (DpstStruct*)ComponentAddress; - - if (SimulationStarted) - { - switch (Event) - { - case EVENT_MOUSE_DOWN: - ToggleState(d, ImageLocation); - EqualiseStaticVoltageDPST(ComponentAddress); - break; - case EVENT_MOUSE_UP: - if (!d->latched) - { - ToggleState(d, ImageLocation); - EqualiseStaticVoltageDPST(ComponentAddress); - } - break; - default: - break; - } - } - else - { - switch (Event) - { - case EVENT_MOUSE_DBLCLICK: - DpstSettingsDialog(ComponentAddress, ImageLocation); - break; - default: - break; - } - } -} - -double DpstVoltChanged(void * ComponentAddress, BOOL SimulationStarted, int index, double Volt, int Source, void * ImageLocation) -{ - if (SimulationStarted) - return EqualiseRuntimeVoltageDPST(ComponentAddress, index, Volt); - - return Volt; -}
\ No newline at end of file diff --git a/ldmicro/components/relay.cpp b/ldmicro/components/relay.cpp deleted file mode 100644 index 262241f..0000000 --- a/ldmicro/components/relay.cpp +++ /dev/null @@ -1,208 +0,0 @@ -#include <wincodec.h> -#include <stdio.h> -#include <math.h> -//#include <string.h> -#include <commctrl.h> -#include <Windowsx.h> - -#include "components.h" -#include "componentstructs.h" -#include "componentfunctions.h" -#include "componentimages.h" - -HWND* RelayDialog; -HWND MinOperatingVoltTextbox; -HWND MaxOperatingVoltTextbox; - -enum RelayPins{ - Coil1 = 0, - Coil2 = 1, - COM = 2, - NO = 3, - NC = 4, -}; - -int InitRelay(void* ComponentAddress) -{ - RelayStruct* temp = (RelayStruct*)ComponentAddress; - temp->Image = RELAY_NC; - temp->MinOperatingVolt = 5; - temp->MaxOperatingVolt = 12; - temp->NC = TRUE; - - return RELAY_NC; -} - -void MakeRelayControls(void) -{ - HWND MinOperatingVoltLabel = CreateWindowEx(0, WC_STATIC, ("Minimum Operating Volt:"), - WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SS_RIGHT, - 5, 21, 100, 21, *RelayDialog, NULL, NULL, NULL); - FontNice(MinOperatingVoltLabel); - - HWND MaxOperatingVoltLabel = CreateWindowEx(0, WC_STATIC, ("Maximum Operating Volt:"), - WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SS_RIGHT, - 5, 41, 100, 21, *RelayDialog, NULL, NULL, NULL); - FontNice(MaxOperatingVoltLabel); - - MinOperatingVoltTextbox = CreateWindowEx(WS_EX_CLIENTEDGE, WC_EDIT, "", - WS_CHILD | ES_AUTOHSCROLL | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE, - 110, 21, 155, 21, *RelayDialog, NULL, NULL, NULL); - FontFixed(MinOperatingVoltTextbox); - - MaxOperatingVoltTextbox = CreateWindowEx(WS_EX_CLIENTEDGE, WC_EDIT, "", - WS_CHILD | ES_AUTOHSCROLL | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE, - 110, 41, 155, 21, *RelayDialog, NULL, NULL, NULL); - FontFixed(MaxOperatingVoltTextbox); - - /*PrevNameProc = SetWindowLongPtr(NameTextbox, GWLP_WNDPROC, - (LONG_PTR)MyNameProc);*/ -} - -void LoadState(RelayStruct* Data) -{ - char Voltage[15]; - sprintf((char*)Voltage,"%f",Data->MinOperatingVolt); - Edit_SetText(MinOperatingVoltTextbox, Voltage); - sprintf((char*)Voltage,"%f",Data->MaxOperatingVolt); - Edit_SetText(MaxOperatingVoltTextbox, Voltage); -} - -BOOL SaveRelayDialog(RelayStruct* Data) -{ - double volt, volt2; - char Voltage[15]; - Edit_GetText(MinOperatingVoltTextbox, (LPSTR)&Voltage, 15); - volt = atof(Voltage); - Edit_GetText(MaxOperatingVoltTextbox, (LPSTR)&Voltage, 15); - volt2 = atof(Voltage); - if(volt == 0.0f) - { - MessageBox(*RelayDialog, - ("Incomplete"), ("Warning"), MB_OK | MB_ICONWARNING); - return FALSE; - } - else if((volt2 == 0.0f) || (volt2<volt)) - { - MessageBox(*RelayDialog, - ("Incomplete"), ("Warning"), MB_OK | MB_ICONWARNING); - return FALSE; - }else - { - Data->MinOperatingVolt = volt; - Data->MaxOperatingVolt = volt2; - } - return TRUE; -} - -void ShowRelayDialog(void* ComponentAddress) -{ - RelayStruct* Data = (RelayStruct*) ComponentAddress; - BOOL Canceled, Complete = TRUE; - RelayDialog = CreateDialogWindow("Relay Dialog", 100, 100, 290, 50, STYLE_HORIZONTAL); - MakeRelayControls(); - ShowDialogWindow(); - LoadState(Data); - Canceled = ProcessDialogWindow(); - while(Canceled == FALSE) - { - Complete = SaveRelayDialog(Data); - if(Complete == TRUE) - { - // MessageBox(*RelayDialog, - // ("Saved"), ("Mouse click"), MB_OK | MB_ICONWARNING); - break; - }else - { - Complete =TRUE; - Canceled = ProcessDialogWindow(); - } - } - DestroyWindow(*RelayDialog); -} - -void HandleRelayEvent(void* ComponentAddress, int Event, BOOL SimulationStarted, - void* ImageLocation, UINT ImageId, HWND* h) -{ - RelayStruct *temp = (RelayStruct*)ComponentAddress; - if(SimulationStarted) - { - /*Relay is a static component. It's value does not change with - direct user interaction hence this part is blank for relays*/ - } - else - { - switch(Event){ - case EVENT_MOUSE_DBLCLICK: - ShowRelayDialog(ComponentAddress); - // SetImage(temp->Image, ImageLocation); - // RefreshImages(); - break; - } - } -} - -double RelayVoltChanged(void* ComponentAddress, BOOL SimulationStarted, int index, - double Volt, int Source, void* ImageLocation) -{ - if(SimulationStarted) - { - RelayStruct *Relay = (RelayStruct*)ComponentAddress; - /*if(index == Coil2) - { - char vx[10],vy[10]; - _gcvt(Volt, 10, vy); - _itoa(index, vx, 10); - MessageBox(NULL, - (LPSTR)(vx), (LPSTR)(vx), MB_OK | MB_ICONWARNING); - }*/ - double Volt2,diff; - switch(index) - { - case Coil1: - Volt2 = VoltRequest(Relay->PinId[Coil2], ComponentAddress); - break; - case Coil2: - Volt2 = VoltRequest(Relay->PinId[Coil1], ComponentAddress); - break; - default: - return Volt; - } - diff = fabs(Volt2-Volt); - if((diff >= Relay->MinOperatingVolt) && (diff <= Relay->MaxOperatingVolt)) - { - Relay->Image = RELAY_NO; - } - else - { - Relay->Image = RELAY_NC; - } - SetImage(Relay->Image, ImageLocation); - RefreshImages(); - } - /*char Debug[256]; - sprintf_s(Debug, "RelayVoltChanged: \tAddr1: %p \t Volt1: %f \t Volt2: %f\n", - ComponentAddress, Volt, Volt2); - OutputDebugString(Debug);*/ - return Volt; -} - -void SetRelayIds(int* id,void* ComponentAddress) -{ - RelayStruct *s = (RelayStruct*)ComponentAddress; - s->PinId[Coil1] = *id++; - s->PinId[Coil2] = *id++; - s->PinId[COM] = *id++; - s->PinId[NO] = *id++; - s->PinId[NC] = *id++; - - /*char Debug[256]; - sprintf_s(Debug, "SetRelayIds: \tAddr1: %p \tAddr2: %p \tPin0:%d \t Pin1:%d \tPin2: %d Pin3: %d\n", - ComponentAddress, s, s->PinId[0], s->PinId[1], s->PinId[2], s->PinId[3]); - OutputDebugString(Debug); - char vx[4],vy[4]; - _itoa(s->PinId[0],vy,10); - _itoa(s->PinId[1],vx,10); - MessageBox(NULL, - (vy), (vx), MB_OK | MB_ICONWARNING);*/ -}
\ No newline at end of file diff --git a/ldmicro/components/spdt.cpp b/ldmicro/components/spdt.cpp deleted file mode 100644 index e30a732..0000000 --- a/ldmicro/components/spdt.cpp +++ /dev/null @@ -1,390 +0,0 @@ -/* SPDT component file -* Code version: 2.0 -* Version description: Adds latching functionality to component -* Version steability: -* GUI -> Stable -* Functionality -> No known bugs. -* Bugs: -* 1. - -* -*/ - -///Includes -#include <wincodec.h> -#include <stdio.h> -//#include <string.h> -#include <commctrl.h> -#include <Windowsx.h> - -#include "componentstructs.h" -#include "componentfunctions.h" -#include "componentimages.h" -#include "components.h" - -///Window handles -static HWND StateOut1; -static HWND StateOut2; -static HWND ModeLatched; -static HWND ModeTemp; -HWND* SettingsDialogSPDT; - -///Global variables -enum SPDT_Pins {in = 0, out1, out2}; - -///Function definitions -void SetSpdtIds(int* id, void* ComponentAddress) -{ - SpdtStruct* s = (SpdtStruct*)ComponentAddress; - s->PinId[in] = *id++; - s->PinId[out1] = *id++; - s->PinId[out2] = *id++; -} - -int InitSpdt(void * ComponentAddress) -{ - SpdtStruct* s = (SpdtStruct*)ComponentAddress; - s->image = SPDT_1; - s->latched = TRUE; - s->NO1 = TRUE; - s->Volt[in] = V_OPEN; - s->Volt[out1] = V_OPEN; - s->Volt[out2] = V_OPEN; - - return SPDT_1; -} - -void MakeSettingsDialogSPDT() -{ - ///Switch action mode - HWND InitLatched = CreateWindowEx(0, WC_BUTTON, ("Action mode"), - WS_CHILD | BS_GROUPBOX | WS_VISIBLE | WS_TABSTOP, - 7, 3, 120, 65, *SettingsDialogSPDT, NULL, NULL, NULL); - FontNice(InitLatched); - - ModeLatched = CreateWindowEx(0, WC_BUTTON, ("Latched"), - WS_CHILD | BS_AUTORADIOBUTTON | WS_TABSTOP | WS_VISIBLE | WS_GROUP, - 16, 21, 100, 20, *SettingsDialogSPDT, NULL, NULL, NULL); - FontNice(ModeLatched); - - ModeTemp = CreateWindowEx(0, WC_BUTTON, ("Temporary"), - WS_CHILD | BS_AUTORADIOBUTTON | WS_TABSTOP | WS_VISIBLE, - 16, 41, 100, 20, *SettingsDialogSPDT, NULL, NULL, NULL); - FontNice(ModeTemp); - - ///Switch initial status - HWND InitOut = CreateWindowEx(0, WC_BUTTON, ("Initial output"), - WS_CHILD | BS_GROUPBOX | WS_VISIBLE | WS_TABSTOP, - 140, 3, 120, 65, *SettingsDialogSPDT, NULL, NULL, NULL); - FontNice(InitOut); - - StateOut1 = CreateWindowEx(0, WC_BUTTON, ("Output 1"), - WS_CHILD | BS_AUTORADIOBUTTON | WS_TABSTOP | WS_VISIBLE | WS_GROUP, - 149, 21, 100, 20, *SettingsDialogSPDT, NULL, NULL, NULL); - FontNice(StateOut1); - - StateOut2 = CreateWindowEx(0, WC_BUTTON, ("Output 2"), - WS_CHILD | BS_AUTORADIOBUTTON | WS_TABSTOP | WS_VISIBLE, - 149, 41, 100, 20, *SettingsDialogSPDT, NULL, NULL, NULL); - FontNice(StateOut2); -} - -void LoadSettings(SpdtStruct* s) -{ - if (s->latched) - Button_SetCheck(ModeLatched, BST_CHECKED); - else - Button_SetCheck(ModeTemp, BST_CHECKED); - if (s->NO1) - Button_SetCheck(StateOut1, BST_CHECKED); - else - Button_SetCheck(StateOut2, BST_CHECKED); -} - -BOOL SaveSettings(SpdtStruct* s, void* ImageLocation) -{ - if (Button_GetState(ModeLatched) == BST_CHECKED) - s->latched = TRUE; - else if (Button_GetState(ModeTemp) == BST_CHECKED) - s->latched = FALSE; - else - { - MessageBox(*SettingsDialogSPDT, - ("Incomplete"), ("Warning"), MB_OK | MB_ICONWARNING); - return FALSE; - } - - if (Button_GetState(StateOut1) == BST_CHECKED) - s->NO1 = TRUE; - else if (Button_GetState(StateOut2) == BST_CHECKED) - s->NO1 = FALSE; - else - { - MessageBox(*SettingsDialogSPDT, - ("Incomplete"), ("Warning"), MB_OK | MB_ICONWARNING); - return FALSE; - } - - - if (s->NO1) - s->image = SPDT_1; - else - s->image = SPDT_2; - - SetImage(s->image, ImageLocation); - RefreshImages(); - - return TRUE; -} - -void SpdtSettingsDialog(void* ComponentAddress, void* ImageLocation) -{ - SpdtStruct* s = (SpdtStruct*)ComponentAddress; - BOOL exitStatus; - - //Create dialog window instance - SettingsDialogSPDT = CreateDialogWindow("SPDT Settings Dialog", 100, 100, 263, 145, STYLE_VERTICAL); - - //Make the settings dialog - MakeSettingsDialogSPDT(); - - //Load settings - LoadSettings(s); - - //Show dialog window - ShowDialogWindow(); - - exitStatus = ProcessDialogWindow(); - while (exitStatus == FALSE) - { - exitStatus = SaveSettings(s, ImageLocation); - if (exitStatus == TRUE) - break; - else - { - exitStatus = TRUE; - exitStatus = ProcessDialogWindow(); - } - } - - DestroyWindow(*SettingsDialogSPDT); - -} - -//Perform a static check and equalise the voltage on all pins that are connected to SPDT at runtime -void EqualiseStaticVoltageSPDT(void* ComponentAdderss) -{ - SpdtStruct* s = (SpdtStruct*)ComponentAdderss; - - ///Check if input and output 1 are connected - if (s->NO1) - { - ///If the input pin is connected to output 1 then output 2 will be open - s->Volt[out2] = VoltChange(s->PinId[out2], out2, ComponentAdderss, V_OPEN); - - ///Get voltages at the connected pins - double volt1 = VoltRequest(s->PinId[in], ComponentAdderss); - double volt2 = VoltRequest(s->PinId[out1], ComponentAdderss); - - ///If either pin is grounded then all pins are set to GND - if (volt1 == GND || volt2 == GND) - { - s->Volt[out1] = VoltChange(s->PinId[out1], out1, ComponentAdderss, GND); - s->Volt[in] = VoltChange(s->PinId[in], in, ComponentAdderss, GND); - } - ///If volt1 is set as open - else if (volt1 == V_OPEN) - s->Volt[in] = VoltChange(s->PinId[in], in, ComponentAdderss, volt2); - ///If volt2 is set as open - else if (volt2 == V_OPEN) - s->Volt[out1] = VoltChange(s->PinId[out1], out1, ComponentAdderss, volt1); - ///If no pin is grounded then all pins are set to the max voltage of the pins - else - { - s->Volt[out1] = VoltChange(s->PinId[out1], out1, ComponentAdderss, max(volt1, volt2)); - s->Volt[in] = VoltChange(s->PinId[in], in, ComponentAdderss, max(volt1, volt2)); - } - } - ///If input and output 2 are connected - else - { - ///If the input pin is connected to output 2 then output 1 will be open - s->Volt[out1] = VoltChange(s->PinId[out1], out1, ComponentAdderss, V_OPEN); - - ///Get voltages at the connected pins - double volt1 = VoltRequest(s->PinId[0], ComponentAdderss); - double volt2 = VoltRequest(s->PinId[out2], ComponentAdderss); - - ///If either pin is grounded then all pins are set to GND (Static event) - if (volt1 == GND || volt2 == GND) - { - s->Volt[out2] = VoltChange(s->PinId[out2], out2, ComponentAdderss, GND); - s->Volt[in] = VoltChange(s->PinId[in], in, ComponentAdderss, GND); - } - ///If volt1 is set as open - else if (volt1 == V_OPEN) - s->Volt[in] = VoltChange(s->PinId[in], in, ComponentAdderss, volt2); - ///If volt2 is set as open - else if (volt2 == V_OPEN) - s->Volt[out2] = VoltChange(s->PinId[out2], out2, ComponentAdderss, volt1); - ///If no pin is grounded then all pins are set to the max voltage of the pins (Dynamic event) - else - { - s->Volt[out2] = VoltChange(s->PinId[out2], out2, ComponentAdderss, max(volt1, volt2)); - s->Volt[in] = VoltChange(s->PinId[in], in, ComponentAdderss, max(volt1, volt2)); - } - } -} - -//Dynamically check and equalise the voltage on all pins that are connected to SPDT at runtime -double EqualiseRuntimeVoltageSPDT(void* ComponentAdderss, int index, double volt) -{ - SpdtStruct* s = (SpdtStruct*)ComponentAdderss; - - ///Check if input and output 1 are connected - if (s->NO1) - { - ///If the input pin is connected to output 1 then output 2 will be open - if (index == out2) - s->Volt[out2] = V_OPEN; - else - s->Volt[out2] = VoltChange(s->PinId[out2], out2, ComponentAdderss, V_OPEN); - - double volt1; - double volt2; - - ///Get voltages at the connected pins - if (index == in) - { - volt1 = volt; - volt2 = VoltRequest(s->PinId[out1], ComponentAdderss); - } - else if (index == out1) - { - volt1 = VoltRequest(s->PinId[in], ComponentAdderss); - volt2 = volt; - } - else - { - volt1 = VoltRequest(s->PinId[in], ComponentAdderss); - volt2 = VoltRequest(s->PinId[out1], ComponentAdderss); - } - - ///If either pin is grounded then all pins are set to GND - if (volt1 == GND || volt2 == GND) - { - s->Volt[out1] = VoltChange(s->PinId[out1], out1, ComponentAdderss, GND); - s->Volt[in] = VoltChange(s->PinId[in], in, ComponentAdderss, GND); - } - ///If volt1 is set as open - else if (volt1 == V_OPEN) - s->Volt[in] = VoltChange(s->PinId[in], in, ComponentAdderss, volt2); - ///If volt2 is set as open - else if (volt2 == V_OPEN) - s->Volt[out1] = VoltChange(s->PinId[out1], out1, ComponentAdderss, volt1); - ///If no pin is grounded then all pins are set to the max voltage of the pins - else - { - s->Volt[out1] = VoltChange(s->PinId[out1], out1, ComponentAdderss, max(volt1, volt2)); - s->Volt[in] = VoltChange(s->PinId[in], in, ComponentAdderss, max(volt1, volt2)); - } - } - ///If input and output 2 are connected - else - { - ///If the input pin is connected to output 2 then output 1 will be open - s->Volt[out1] = VoltChange(s->PinId[out1], out1, ComponentAdderss, V_OPEN); - - double volt1; - double volt2; - - ///Get voltages at the connected pins - if (index == in) - { - volt1 = volt; - volt2 = VoltRequest(s->PinId[out2], ComponentAdderss); - } - else if (index == out1) - { - volt1 = VoltRequest(s->PinId[in], ComponentAdderss); - volt2 = volt; - } - else - { - volt1 = VoltRequest(s->PinId[in], ComponentAdderss); - volt2 = VoltRequest(s->PinId[out2], ComponentAdderss); - } - - ///If either pin is grounded then all pins are set to GND (Static event) - if (volt1 == GND || volt2 == GND) - { - s->Volt[out2] = VoltChange(s->PinId[out2], out2, ComponentAdderss, GND); - s->Volt[in] = VoltChange(s->PinId[in], in, ComponentAdderss, GND); - } - ///If volt1 is set as open - else if (volt1 == V_OPEN) - s->Volt[in] = VoltChange(s->PinId[in], in, ComponentAdderss, volt2); - ///If volt2 is set as open - else if (volt2 == V_OPEN) - s->Volt[out2] = VoltChange(s->PinId[out2], out2, ComponentAdderss, volt1); - ///If no pin is grounded then all pins are set to the max voltage of the pins (Dynamic event) - else - { - s->Volt[out2] = VoltChange(s->PinId[out2], out2, ComponentAdderss, max(volt1, volt2)); - s->Volt[in] = VoltChange(s->PinId[in], in, ComponentAdderss, max(volt1, volt2)); - } - } - - return s->Volt[index]; -} - -double SpdtVoltChanged(void * ComponentAddress, BOOL SimulationStarted, int index, double Volt, int Source, void * ImageLocation) -{ - if (SimulationStarted) - return EqualiseRuntimeVoltageSPDT(ComponentAddress, index, Volt); - - return Volt; -} - -void ToggleState(SpdtStruct* s, void* ImageLocation) -{ - s->image = (s->image == SPDT_1) ? SPDT_2 : SPDT_1; - s->NO1 = (s->NO1 == TRUE) ? FALSE : TRUE; - SetImage(s->image, ImageLocation); - RefreshImages(); -} - -void HandleSpdtEvent(void * ComponentAddress, int Event, BOOL SimulationStarted, void * ImageLocation, UINT ImageId, HWND * h) -{ - SpdtStruct* s = (SpdtStruct*)ComponentAddress; - - if (SimulationStarted) - { - switch (Event) - { - case EVENT_MOUSE_DOWN: - ToggleState(s, ImageLocation); - EqualiseStaticVoltageSPDT(ComponentAddress); - break; - case EVENT_MOUSE_UP: - if (!s->latched) - { - ToggleState(s, ImageLocation); - EqualiseStaticVoltageSPDT(ComponentAddress); - } - break; - default: - break; - } - } - else - { - switch (Event) - { - case EVENT_MOUSE_DBLCLICK: - SpdtSettingsDialog(ComponentAddress, ImageLocation); - break; - default: - break; - } - } -}
\ No newline at end of file diff --git a/ldmicro/components/switch.cpp b/ldmicro/components/switch.cpp deleted file mode 100644 index ea74076..0000000 --- a/ldmicro/components/switch.cpp +++ /dev/null @@ -1,355 +0,0 @@ -#include <wincodec.h> -#include <stdio.h> -//#include <string.h> -#include <commctrl.h> -#include <Windowsx.h> - -#include "componentstructs.h" -#include "componentfunctions.h" -#include "componentimages.h" -#include "components.h" - -static HWND TemporaryRadio; -static HWND LatchedRadio; -static HWND ClosedRadio; -static HWND OpenRadio; -static HWND NameTextbox; -static HWND InNameTextbox; -static HWND OutNameTextbox; -HWND* SwitchDialog; - -void SwitchStateChanged(SwitchStruct* SwitchData, void* ImageLocation); -void MakeSwitchControls() -{ - HWND ActionGrouper = CreateWindowEx(0, WC_BUTTON, ("Action"), - WS_CHILD | BS_GROUPBOX | WS_VISIBLE | WS_TABSTOP, - 7, 3, 120, 65, *SwitchDialog, NULL, NULL, NULL); - FontNice(ActionGrouper); - - LatchedRadio = CreateWindowEx(0, WC_BUTTON, ("Latched"), - WS_CHILD | BS_AUTORADIOBUTTON | WS_TABSTOP | WS_VISIBLE | WS_GROUP, - 16, 21, 100, 20, *SwitchDialog, NULL, NULL, NULL); - FontNice(LatchedRadio); - - TemporaryRadio = CreateWindowEx(0, WC_BUTTON, ("Temporary"), - WS_CHILD | BS_AUTORADIOBUTTON | WS_TABSTOP | WS_VISIBLE, - 16, 41, 100, 20, *SwitchDialog, NULL, NULL, NULL); - FontNice(TemporaryRadio); - - // SetOnlyRadio = CreateWindowEx(0, WC_BUTTON, _("(S) Set-Only"), - // WS_CHILD | BS_AUTORADIOBUTTON | WS_TABSTOP | WS_VISIBLE, - // 16, 61, 100, 20, CoilDialog, NULL, Instance, NULL); - // NiceFont(SetOnlyRadio); - - // ResetOnlyRadio = CreateWindowEx(0, WC_BUTTON, _("(R) Reset-Only"), - // WS_CHILD | BS_AUTORADIOBUTTON | WS_TABSTOP | WS_VISIBLE, - // 16, 81, 105, 20, CoilDialog, NULL, Instance, NULL); - // NiceFont(ResetOnlyRadio); - - HWND PositionGrouper = CreateWindowEx(0, WC_BUTTON, ("Position"), - WS_CHILD | BS_GROUPBOX | WS_VISIBLE, - 140, 3, 120, 65, *SwitchDialog, NULL, NULL, NULL); - FontNice(PositionGrouper); - - OpenRadio = CreateWindowEx(0, WC_BUTTON, ("Open"), - WS_CHILD | BS_AUTORADIOBUTTON | WS_VISIBLE | WS_GROUP | WS_TABSTOP, - 149, 21, 100, 20, *SwitchDialog, NULL, NULL, NULL); - FontNice(OpenRadio); - - ClosedRadio = CreateWindowEx(0, WC_BUTTON, ("Closed"), - WS_CHILD | BS_AUTORADIOBUTTON | WS_VISIBLE | WS_TABSTOP, - 149, 41, 100, 20, *SwitchDialog, NULL, NULL, NULL); - FontNice(ClosedRadio); - - HWND textLabel = CreateWindowEx(0, WC_STATIC, ("Name:"), - WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SS_RIGHT, - 100, 80, 50, 21, *SwitchDialog, NULL, NULL, NULL); - FontNice(textLabel); - - NameTextbox = CreateWindowEx(WS_EX_CLIENTEDGE, WC_EDIT, "", - WS_CHILD | ES_AUTOHSCROLL | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE, - 155, 80, 155, 21, *SwitchDialog, NULL, NULL, NULL); - FontFixed(NameTextbox); - - /*PrevNameProc = SetWindowLongPtr(NameTextbox, GWLP_WNDPROC, - (LONG_PTR)MyNameProc);*/ -} - -void LoadState(SwitchStruct* Data) -{ - if(Data->Latched) - { - Button_SetCheck(LatchedRadio, BST_CHECKED); - }else - { - Button_SetCheck(TemporaryRadio, BST_CHECKED); - } - if(Data->NOpen) - { - Button_SetCheck(OpenRadio, BST_CHECKED); - } - else - { - Button_SetCheck(ClosedRadio, BST_CHECKED); - } - Edit_SetText(NameTextbox, Data->Name); -} - -BOOL SaveSwitchDialog(SwitchStruct* Data) -{ - char temp[15]; - BOOL Latched, NOpen; - if(Button_GetState(LatchedRadio) == BST_CHECKED) - { - Latched = TRUE; - - }else if(Button_GetState(TemporaryRadio) == BST_CHECKED) - { - Latched = FALSE; - }else - { - MessageBox(*SwitchDialog, - ("Incomplete"), ("Warning"), MB_OK | MB_ICONWARNING); - return FALSE; - } - - if(Button_GetState(OpenRadio) == BST_CHECKED) - { - NOpen = TRUE; - - }else if(Button_GetState(ClosedRadio) == BST_CHECKED) - { - NOpen = FALSE; - }else - { - MessageBox(*SwitchDialog, - ("Incomplete"), ("Warning"), MB_OK | MB_ICONWARNING); - return FALSE; - } - - if(Edit_GetText(NameTextbox, (LPSTR)&temp, 15) < 1) - { - MessageBox(*SwitchDialog, - ("Incomplete"), ("Warning"), MB_OK | MB_ICONWARNING); - return FALSE; - }else - { - Data->Latched = Latched; - Data-> NOpen = NOpen; - Data-> Open = NOpen; - strcpy(Data->Name, temp); - if(NOpen) - { - Data->Image =SWITCH_DISCONNECTED; - } - else - { - Data->Image =SWITCH_CONNECTED; - } - } - return TRUE; -} - -void ShowSwitchDialog(void* ComponentAddress) -{ - SwitchStruct* Data = (SwitchStruct*) ComponentAddress; - BOOL Canceled, Complete = TRUE; - SwitchDialog = CreateDialogWindow("Switch Dialog", 100, 100, 263, 145, STYLE_VERTICAL); - MakeSwitchControls(); - ShowDialogWindow(); - LoadState(Data); - Canceled = ProcessDialogWindow(); - while(Canceled == FALSE) - { - Complete = SaveSwitchDialog(Data); - if(Complete == TRUE) - { - // MessageBox(*SwitchDialog, - // ("Saved"), ("Mouse click"), MB_OK | MB_ICONWARNING); - break; - }else - { - Complete =TRUE; - Canceled = ProcessDialogWindow(); - } - } - DestroyWindow(*SwitchDialog); -} - -int InitSwitch(void* ComponentAddress) -{ - SwitchStruct* temp = (SwitchStruct*)ComponentAddress; - temp->Image = SWITCH_DISCONNECTED; - temp->Latched = TRUE; - temp->Open = TRUE; - temp->NOpen = TRUE; - temp->Volt[0] = V_OPEN; - temp->Volt[1] = V_OPEN; - - return SWITCH_DISCONNECTED; -} - -void UpdateValues(SwitchStruct* Switch, void* ComponentAddress) -{ - /*char Debug[256]; - sprintf_s(Debug, "Clicked: %p\n", ComponentAddress); - OutputDebugString(Debug);*/ - if(Switch->Open) - { - Switch->Volt[0] = - VoltChange(Switch->PinId[0], 0, ComponentAddress, V_OPEN); - Switch->Volt[1] = - VoltChange(Switch->PinId[1], 1, ComponentAddress, V_OPEN); - // char vx[3],vy[10]; - // _gcvt(Switch->Volt[0],8,vy); - // _itoa(Switch->PinId[0],vx,10); - // MessageBox(NULL, - // (vx),(vy), MB_OK | MB_ICONWARNING); - // Switch->Volt[1] = GlobalVoltChange(Switch->PinId[1], ComponentAddress, V_OPEN); - // MessageBox(NULL, - // "Open", "Test", MB_OK | MB_ICONWARNING); - } - else - { - double Voltage; - Voltage = VoltRequest(Switch->PinId[0], ComponentAddress); - Switch->Volt[0] = Voltage; - Voltage = VoltRequest(Switch->PinId[1], ComponentAddress); - Switch->Volt[1] = Voltage; - if(Switch->Volt[0] > Switch->Volt[1]) - { - /*sprintf_s(Debug, "Values2: Volt1:%f \t Volt2:%f \tAddr: %p \tPin0:%d \t Pin1:%d\n", - Switch->Volt[0], Switch->Volt[1], ComponentAddress, Switch->PinId[0], Switch->PinId[1]); - OutputDebugString(Debug);*/ - Switch->Volt[0] = VoltChange(Switch->PinId[0], 0, - ComponentAddress, Switch->Volt[1]); - } - else if(Switch->Volt[1] > Switch->Volt[0]) - { - /*sprintf_s(Debug, "Values3: Volt1:%f \t Volt2:%f \tAddr: %p \tPin0:%d \t Pin1:%d\n", - Switch->Volt[0], Switch->Volt[1], ComponentAddress, Switch->PinId[0], Switch->PinId[1]); - OutputDebugString(Debug);*/ - Switch->Volt[1] = VoltChange(Switch->PinId[1], 1, - ComponentAddress, Switch->Volt[0]); - - } - } - /*sprintf_s(Debug, "Values: Volt1:%f \t Volt2:%f \tAddr: %p \tPin0:%d \t Pin1:%d\n", - Switch->Volt[0], Switch->Volt[1], ComponentAddress, Switch->PinId[0], Switch->PinId[1]); - OutputDebugString(Debug);*/ -} - -void HandleSwitchEvent(void* ComponentAddress, int Event, BOOL SimulationStarted, - void* ImageLocation, UINT ImageId, HWND* h) -{ - SwitchStruct *temp = (SwitchStruct*)ComponentAddress; - - if(SimulationStarted) - { - switch(Event){ - case EVENT_MOUSE_UP: - if(temp->Latched) - { - temp->Open = !temp->Open; - /*MessageBox(NULL, - "Latched", "Test", MB_OK | MB_ICONWARNING);*/ - } - else - { - temp->Open = temp->NOpen; - // MessageBox(NULL, - // "Latched", "Test", MB_OK | MB_ICONWARNING); - } - SwitchStateChanged(temp, ImageLocation); - UpdateValues(temp, ComponentAddress); - break; - case EVENT_MOUSE_DOWN: - if(!temp->Latched) - { - temp->Open = !temp->NOpen; - SwitchStateChanged(temp, ImageLocation); - UpdateValues(temp, ComponentAddress); - } - break; - } - - } - else - { - switch(Event){ - case EVENT_MOUSE_DBLCLICK: - ShowSwitchDialog(ComponentAddress); - SetImage(temp->Image, ImageLocation); - RefreshImages(); - break; - } - } -} - -void SwitchStateChanged(SwitchStruct* SwitchData, void* ImageLocation) -{ - SetImage(SwitchData->Open ? SWITCH_DISCONNECTED : SWITCH_CONNECTED, - ImageLocation); - RefreshImages(); -} - -double SwitchVoltChanged(void* SwitchData, BOOL SimulationStarted, int Index, - double Volt, int Source, void* ImageLocation) -{ - // char Debug[256]; - SwitchStruct* temp = (SwitchStruct*)SwitchData; - if(SimulationStarted) - { - double Voltage; - Voltage = VoltRequest(temp->PinId[!Index], SwitchData); - if(temp->Open) - { - temp->Volt[!Index] = VoltChange(temp->PinId[!Index], !Index, SwitchData, V_OPEN); - temp->Volt[Index] = V_OPEN; - /*sprintf_s(Debug, "SwitchVoltChanged: \tAddress: %p \tVolt0:%f \t Volt1:%f\n", - SwitchData, Voltage, Volt); - OutputDebugString(Debug);*/ - return temp->Volt[Index]; - } - if(Voltage > Volt) - { - temp->Volt[Index] = Volt; - temp->Volt[!Index] = VoltChange(temp->PinId[!Index], !Index, SwitchData, Volt); - /*sprintf_s(Debug, "SwitchVoltChanged2: \tAddress: %p \tVolt0:%f \t Volt1:%f\n", - SwitchData, Voltage, Volt); - OutputDebugString(Debug);*/ - return temp->Volt[Index]; - } - else - { - // temp->Volt[!Index] = VoltChange(temp->PinId[!Index], !Index, SwitchData, Volt); - Voltage = VoltChange(temp->PinId[!Index], !Index, SwitchData, Volt); - temp->Volt[Index] = Voltage; - // VoltChange(temp->PinId[!Index], !Index, SwitchData, Volt); - return Voltage; - } - } - else - { - temp->Volt[Index] = Volt; - return Volt; - } - return 0; -} - -void SetSwitchIds(int* id,void* ComponentAddress) -{ - SwitchStruct *s = (SwitchStruct*)ComponentAddress; - s->PinId[0] = *id++; - s->PinId[1] = *id; - /*char Debug[256]; - sprintf_s(Debug, "SetSwitchIds: \tAddr1: %p \tAddr2: %p \tPin0:%d \t Pin1:%d \tVolt0: %f Volt1: %f\n", - ComponentAddress, s, s->PinId[0], s->PinId[1],VoltRequest(s->PinId[0], ComponentAddress), - VoltRequest(s->PinId[0], ComponentAddress)); - OutputDebugString(Debug); - char vx[4],vy[4]; - _itoa(s->PinId[0],vy,10); - _itoa(s->PinId[1],vx,10); - MessageBox(NULL, - (vy), (vx), MB_OK | MB_ICONWARNING);*/ -}
\ No newline at end of file diff --git a/ldmicro/confdialog.cpp b/ldmicro/confdialog.cpp index 3967fc7..1b77fd0 100644 --- a/ldmicro/confdialog.cpp +++ b/ldmicro/confdialog.cpp @@ -22,18 +22,18 @@ // which is configurable, plus the MCU clock (i.e. crystal frequency). // Jonathan Westhues, Nov 2004 //----------------------------------------------------------------------------- -#include <windows.h> +#include <linuxUI.h> #include <stdio.h> #include <stdlib.h> -#include <commctrl.h> +//#include <commctrl.h> #include "ldmicro.h" -static HWND ConfDialog; +// static HWND ConfDialog; -static HWND CrystalTextbox; -static HWND CycleTextbox; -static HWND BaudTextbox; +// static HWND CrystalTextbox; +// static HWND CycleTextbox; +// static HWND BaudTextbox; static LONG_PTR PrevCrystalProc; static LONG_PTR PrevCycleProc; @@ -42,208 +42,208 @@ static LONG_PTR PrevBaudProc; //----------------------------------------------------------------------------- // Don't allow any characters other than 0-9. in the text boxes. //----------------------------------------------------------------------------- -static LRESULT CALLBACK MyNumberProc(HWND hwnd, UINT msg, WPARAM wParam, - LPARAM lParam) -{ - if(msg == WM_CHAR) { - if(!(isdigit(wParam) || wParam == '.' || wParam == '\b')) { - return 0; - } - } - - LONG_PTR t; - if(hwnd == CrystalTextbox) - t = PrevCrystalProc; - else if(hwnd == CycleTextbox) - t = PrevCycleProc; - else if(hwnd == BaudTextbox) - t = PrevBaudProc; - else - oops(); - - return CallWindowProc((WNDPROC)t, hwnd, msg, wParam, lParam); -} - -static void MakeControls(void) -{ - HWND textLabel = CreateWindowEx(0, WC_STATIC, _("Cycle Time (ms):"), - WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SS_RIGHT, - 5, 13, 145, 21, ConfDialog, NULL, Instance, NULL); - NiceFont(textLabel); - - CycleTextbox = CreateWindowEx(WS_EX_CLIENTEDGE, WC_EDIT, "", - WS_CHILD | ES_AUTOHSCROLL | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE, - 155, 12, 85, 21, ConfDialog, NULL, Instance, NULL); - NiceFont(CycleTextbox); - - HWND textLabel2 = CreateWindowEx(0, WC_STATIC, - _("Crystal Frequency (MHz):"), - WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SS_RIGHT, - 0, 43, 150, 21, ConfDialog, NULL, Instance, NULL); - NiceFont(textLabel2); - - CrystalTextbox = CreateWindowEx(WS_EX_CLIENTEDGE, WC_EDIT, "", - WS_CHILD | ES_AUTOHSCROLL | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE, - 155, 42, 85, 21, ConfDialog, NULL, Instance, NULL); - NiceFont(CrystalTextbox); - - HWND textLabel3 = CreateWindowEx(0, WC_STATIC, _("UART Baud Rate (bps):"), - WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SS_RIGHT, - 5, 73, 145, 21, ConfDialog, NULL, Instance, NULL); - NiceFont(textLabel3); - - BaudTextbox = CreateWindowEx(WS_EX_CLIENTEDGE, WC_EDIT, "", - WS_CHILD | ES_AUTOHSCROLL | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE, - 155, 72, 85, 21, ConfDialog, NULL, Instance, NULL); - NiceFont(BaudTextbox); - - if(!UartFunctionUsed()) { - EnableWindow(BaudTextbox, FALSE); - EnableWindow(textLabel3, FALSE); - } - - if(Prog.mcu && (Prog.mcu->whichIsa == ISA_ANSIC || - Prog.mcu->whichIsa == ISA_INTERPRETED)) - { - EnableWindow(CrystalTextbox, FALSE); - EnableWindow(textLabel2, FALSE); - } - - OkButton = CreateWindowEx(0, WC_BUTTON, _("OK"), - WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE | BS_DEFPUSHBUTTON, - 258, 11, 70, 23, ConfDialog, NULL, Instance, NULL); - NiceFont(OkButton); - - CancelButton = CreateWindowEx(0, WC_BUTTON, _("Cancel"), - WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE, - 258, 41, 70, 23, ConfDialog, NULL, Instance, NULL); - NiceFont(CancelButton); - - char explanation[1024] = ""; - - if(UartFunctionUsed()) { - if(Prog.mcu && Prog.mcu->uartNeeds.rxPin != 0) { - sprintf(explanation, - _("Serial (UART) will use pins %d and %d.\r\n\r\n"), - Prog.mcu->uartNeeds.rxPin, Prog.mcu->uartNeeds.txPin); - } else { - strcpy(explanation, - _("Please select a micro with a UART.\r\n\r\n")); - } - } else { - strcpy(explanation, _("No serial instructions (UART Send/UART Receive) " - "are in use; add one to program before setting baud rate.\r\n\r\n") - ); - } - - strcat(explanation, - _("The cycle time for the 'PLC' runtime generated by LDmicro is user-" - "configurable. Very short cycle times may not be achievable due " - "to processor speed constraints, and very long cycle times may not " - "be achievable due to hardware overflows. Cycle times between 10 ms " - "and 100 ms will usually be practical.\r\n\r\n" - "The compiler must know what speed crystal you are using with the " - "micro to convert between timing in clock cycles and timing in " - "seconds. A 4 MHz to 20 MHz crystal is typical; check the speed " - "grade of the part you are using to determine the maximum allowable " - "clock speed before choosing a crystal.")); - - HWND textLabel4 = CreateWindowEx(0, WC_STATIC, explanation, - WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE, - 11, 104, 310, 400, ConfDialog, NULL, Instance, NULL); - NiceFont(textLabel4); - - // Measure the explanation string, so that we know how to size our window - RECT tr, cr; - HDC hdc = CreateCompatibleDC(NULL); - SelectObject(hdc, MyNiceFont); - SetRect(&tr, 0, 0, 310, 400); - DrawText(hdc, explanation, -1, &tr, DT_CALCRECT | - DT_LEFT | DT_TOP | DT_WORDBREAK); - DeleteDC(hdc); - int h = 104 + tr.bottom + 10; - SetWindowPos(ConfDialog, NULL, 0, 0, 344, h, SWP_NOMOVE); - // h is the desired client height, but SetWindowPos includes title bar; - // so fix it up by hand - GetClientRect(ConfDialog, &cr); - int nh = h + (h - (cr.bottom - cr.top)); - SetWindowPos(ConfDialog, NULL, 0, 0, 344, nh, SWP_NOMOVE); - - - PrevCycleProc = SetWindowLongPtr(CycleTextbox, GWLP_WNDPROC, - (LONG_PTR)MyNumberProc); - - PrevCrystalProc = SetWindowLongPtr(CrystalTextbox, GWLP_WNDPROC, - (LONG_PTR)MyNumberProc); - - PrevBaudProc = SetWindowLongPtr(BaudTextbox, GWLP_WNDPROC, - (LONG_PTR)MyNumberProc); -} - -void ShowConfDialog(void) -{ - // The window's height will be resized later, to fit the explanation text. - ConfDialog = CreateWindowClient(0, "LDmicroDialog", _("PLC Configuration"), - WS_OVERLAPPED | WS_SYSMENU, - 100, 100, 0, 0, NULL, NULL, Instance, NULL); - - MakeControls(); +// static LRESULT CALLBACK MyNumberProc(HWND hwnd, UINT msg, WPARAM wParam, +// LPARAM lParam) +// { +// if(msg == WM_CHAR) { +// if(!(isdigit(wParam) || wParam == '.' || wParam == '\b')) { +// return 0; +// } +// } + +// LONG_PTR t; +// if(hwnd == CrystalTextbox) +// t = PrevCrystalProc; +// else if(hwnd == CycleTextbox) +// t = PrevCycleProc; +// else if(hwnd == BaudTextbox) +// t = PrevBaudProc; +// else +// oops(); + +// return CallWindowProc((WNDPROC)t, hwnd, msg, wParam, lParam); +// } + +// static void MakeControls(void) +// { +// HWND textLabel = CreateWindowEx(0, WC_STATIC, _("Cycle Time (ms):"), +// WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SS_RIGHT, +// 5, 13, 145, 21, ConfDialog, NULL, Instance, NULL); +// NiceFont(textLabel); + +// CycleTextbox = CreateWindowEx(WS_EX_CLIENTEDGE, WC_EDIT, "", +// WS_CHILD | ES_AUTOHSCROLL | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE, +// 155, 12, 85, 21, ConfDialog, NULL, Instance, NULL); +// NiceFont(CycleTextbox); + +// HWND textLabel2 = CreateWindowEx(0, WC_STATIC, +// _("Crystal Frequency (MHz):"), +// WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SS_RIGHT, +// 0, 43, 150, 21, ConfDialog, NULL, Instance, NULL); +// NiceFont(textLabel2); + +// CrystalTextbox = CreateWindowEx(WS_EX_CLIENTEDGE, WC_EDIT, "", +// WS_CHILD | ES_AUTOHSCROLL | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE, +// 155, 42, 85, 21, ConfDialog, NULL, Instance, NULL); +// NiceFont(CrystalTextbox); + +// HWND textLabel3 = CreateWindowEx(0, WC_STATIC, _("UART Baud Rate (bps):"), +// WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SS_RIGHT, +// 5, 73, 145, 21, ConfDialog, NULL, Instance, NULL); +// NiceFont(textLabel3); + +// BaudTextbox = CreateWindowEx(WS_EX_CLIENTEDGE, WC_EDIT, "", +// WS_CHILD | ES_AUTOHSCROLL | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE, +// 155, 72, 85, 21, ConfDialog, NULL, Instance, NULL); +// NiceFont(BaudTextbox); + +// if(!UartFunctionUsed()) { +// EnableWindow(BaudTextbox, FALSE); +// EnableWindow(textLabel3, FALSE); +// } + +// if(Prog.mcu && (Prog.mcu->whichIsa == ISA_ANSIC || +// Prog.mcu->whichIsa == ISA_INTERPRETED)) +// { +// EnableWindow(CrystalTextbox, FALSE); +// EnableWindow(textLabel2, FALSE); +// } + +// OkButton = CreateWindowEx(0, WC_BUTTON, _("OK"), +// WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE | BS_DEFPUSHBUTTON, +// 258, 11, 70, 23, ConfDialog, NULL, Instance, NULL); +// NiceFont(OkButton); + +// CancelButton = CreateWindowEx(0, WC_BUTTON, _("Cancel"), +// WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE, +// 258, 41, 70, 23, ConfDialog, NULL, Instance, NULL); +// NiceFont(CancelButton); + +// char explanation[1024] = ""; + +// if(UartFunctionUsed()) { +// if(Prog.mcu && Prog.mcu->uartNeeds.rxPin != 0) { +// sprintf(explanation, +// _("Serial (UART) will use pins %d and %d.\r\n\r\n"), +// Prog.mcu->uartNeeds.rxPin, Prog.mcu->uartNeeds.txPin); +// } else { +// strcpy(explanation, +// _("Please select a micro with a UART.\r\n\r\n")); +// } +// } else { +// strcpy(explanation, _("No serial instructions (UART Send/UART Receive) " +// "are in use; add one to program before setting baud rate.\r\n\r\n") +// ); +// } + +// strcat(explanation, +// _("The cycle time for the 'PLC' runtime generated by LDmicro is user-" +// "configurable. Very short cycle times may not be achievable due " +// "to processor speed constraints, and very long cycle times may not " +// "be achievable due to hardware overflows. Cycle times between 10 ms " +// "and 100 ms will usually be practical.\r\n\r\n" +// "The compiler must know what speed crystal you are using with the " +// "micro to convert between timing in clock cycles and timing in " +// "seconds. A 4 MHz to 20 MHz crystal is typical; check the speed " +// "grade of the part you are using to determine the maximum allowable " +// "clock speed before choosing a crystal.")); + +// HWND textLabel4 = CreateWindowEx(0, WC_STATIC, explanation, +// WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE, +// 11, 104, 310, 400, ConfDialog, NULL, Instance, NULL); +// NiceFont(textLabel4); + +// // Measure the explanation string, so that we know how to size our window +// RECT tr, cr; +// HDC hdc = CreateCompatibleDC(NULL); +// SelectObject(hdc, MyNiceFont); +// SetRect(&tr, 0, 0, 310, 400); +// DrawText(hdc, explanation, -1, &tr, DT_CALCRECT | +// DT_LEFT | DT_TOP | DT_WORDBREAK); +// DeleteDC(hdc); +// int h = 104 + tr.bottom + 10; +// SetWindowPos(ConfDialog, NULL, 0, 0, 344, h, SWP_NOMOVE); +// // h is the desired client height, but SetWindowPos includes title bar; +// // so fix it up by hand +// GetClientRect(ConfDialog, &cr); +// int nh = h + (h - (cr.bottom - cr.top)); +// SetWindowPos(ConfDialog, NULL, 0, 0, 344, nh, SWP_NOMOVE); + + +// PrevCycleProc = SetWindowLongPtr(CycleTextbox, GWLP_WNDPROC, +// (LONG_PTR)MyNumberProc); + +// PrevCrystalProc = SetWindowLongPtr(CrystalTextbox, GWLP_WNDPROC, +// (LONG_PTR)MyNumberProc); + +// PrevBaudProc = SetWindowLongPtr(BaudTextbox, GWLP_WNDPROC, +// (LONG_PTR)MyNumberProc); +// } + +// void ShowConfDialog(void) +// { +// // The window's height will be resized later, to fit the explanation text. +// ConfDialog = CreateWindowClient(0, "LDmicroDialog", _("PLC Configuration"), +// WS_OVERLAPPED | WS_SYSMENU, +// 100, 100, 0, 0, NULL, NULL, Instance, NULL); + +// MakeControls(); - char buf[16]; - sprintf(buf, "%.1f", (Prog.cycleTime / 1000.0)); - SendMessage(CycleTextbox, WM_SETTEXT, 0, (LPARAM)buf); - - sprintf(buf, "%.6f", Prog.mcuClock / 1e6); - SendMessage(CrystalTextbox, WM_SETTEXT, 0, (LPARAM)buf); - - sprintf(buf, "%d", Prog.baudRate); - SendMessage(BaudTextbox, WM_SETTEXT, 0, (LPARAM)buf); - - EnableWindow(MainWindow, FALSE); - ShowWindow(ConfDialog, TRUE); - SetFocus(CycleTextbox); - - MSG msg; - DWORD ret; - DialogDone = FALSE; - DialogCancel = FALSE; - while((ret = GetMessage(&msg, NULL, 0, 0)) && !DialogDone) { - if(msg.message == WM_KEYDOWN) { - if(msg.wParam == VK_RETURN) { - DialogDone = TRUE; - break; - } else if(msg.wParam == VK_ESCAPE) { - DialogDone = TRUE; - DialogCancel = TRUE; - break; - } - } - - if(IsDialogMessage(ConfDialog, &msg)) continue; - TranslateMessage(&msg); - DispatchMessage(&msg); - } - - if(!DialogCancel) { - char buf[16]; - SendMessage(CycleTextbox, WM_GETTEXT, (WPARAM)sizeof(buf), - (LPARAM)(buf)); - Prog.cycleTime = (int)(1000*atof(buf) + 0.5); - if(Prog.cycleTime == 0) { - Error(_("Zero cycle time not valid; resetting to 10 ms.")); - Prog.cycleTime = 10000; - } - - SendMessage(CrystalTextbox, WM_GETTEXT, (WPARAM)sizeof(buf), - (LPARAM)(buf)); - Prog.mcuClock = (int)(1e6*atof(buf) + 0.5); - - SendMessage(BaudTextbox, WM_GETTEXT, (WPARAM)sizeof(buf), - (LPARAM)(buf)); - Prog.baudRate = atoi(buf); - } - - EnableWindow(MainWindow, TRUE); - DestroyWindow(ConfDialog); - return; -} +// char buf[16]; +// sprintf(buf, "%.1f", (Prog.cycleTime / 1000.0)); +// SendMessage(CycleTextbox, WM_SETTEXT, 0, (LPARAM)buf); + +// sprintf(buf, "%.6f", Prog.mcuClock / 1e6); +// SendMessage(CrystalTextbox, WM_SETTEXT, 0, (LPARAM)buf); + +// sprintf(buf, "%d", Prog.baudRate); +// SendMessage(BaudTextbox, WM_SETTEXT, 0, (LPARAM)buf); + +// EnableWindow(MainWindow, FALSE); +// ShowWindow(ConfDialog, TRUE); +// SetFocus(CycleTextbox); + +// MSG msg; +// DWORD ret; +// DialogDone = FALSE; +// DialogCancel = FALSE; +// while((ret = GetMessage(&msg, NULL, 0, 0)) && !DialogDone) { +// if(msg.message == WM_KEYDOWN) { +// if(msg.wParam == VK_RETURN) { +// DialogDone = TRUE; +// break; +// } else if(msg.wParam == VK_ESCAPE) { +// DialogDone = TRUE; +// DialogCancel = TRUE; +// break; +// } +// } + +// if(IsDialogMessage(ConfDialog, &msg)) continue; +// TranslateMessage(&msg); +// DispatchMessage(&msg); +// } + +// if(!DialogCancel) { +// char buf[16]; +// SendMessage(CycleTextbox, WM_GETTEXT, (WPARAM)sizeof(buf), +// (LPARAM)(buf)); +// Prog.cycleTime = (int)(1000*atof(buf) + 0.5); +// if(Prog.cycleTime == 0) { +// Error(_("Zero cycle time not valid; resetting to 10 ms.")); +// Prog.cycleTime = 10000; +// } + +// SendMessage(CrystalTextbox, WM_GETTEXT, (WPARAM)sizeof(buf), +// (LPARAM)(buf)); +// Prog.mcuClock = (int)(1e6*atof(buf) + 0.5); + +// SendMessage(BaudTextbox, WM_GETTEXT, (WPARAM)sizeof(buf), +// (LPARAM)(buf)); +// Prog.baudRate = atoi(buf); +// } + +// EnableWindow(MainWindow, TRUE); +// DestroyWindow(ConfDialog); +// return; +// } diff --git a/ldmicro/contactsdialog.cpp b/ldmicro/contactsdialog.cpp index a6788fc..fe2922c 100644 --- a/ldmicro/contactsdialog.cpp +++ b/ldmicro/contactsdialog.cpp @@ -21,9 +21,9 @@ // plus the name // Jonathan Westhues, Oct 2004 //----------------------------------------------------------------------------- -#include <windows.h> +#include <linuxUI.h> #include <stdio.h> -#include <commctrl.h> +//#include <commctrl.h> #include "ldmicro.h" diff --git a/ldmicro/draw.cpp b/ldmicro/draw.cpp index 83ab7b3..75fcf54 100644 --- a/ldmicro/draw.cpp +++ b/ldmicro/draw.cpp @@ -23,7 +23,7 @@ // with wires. // Jonathan Westhues, Oct 2004 //----------------------------------------------------------------------------- -#include <windows.h> +#include "linuxUI.h" #include <stdio.h> #include <stdlib.h> diff --git a/ldmicro/draw_outputdev.cpp b/ldmicro/draw_outputdev.cpp index 0d6f3cd..5b05db5 100644 --- a/ldmicro/draw_outputdev.cpp +++ b/ldmicro/draw_outputdev.cpp @@ -83,26 +83,26 @@ SyntaxHighlightingColours HighlightColours; //----------------------------------------------------------------------------- void CALLBACK BlinkCursor(HWND hwnd, UINT msg, UINT_PTR id, DWORD time) { - if(!isFocus(MainWindow) && !CursorDrawn) return; - if(Cursor.left == 0) return; + // if(!isFocus(MainWindow) && !CursorDrawn) return; + // if(Cursor.left == 0) return; - PlcCursor c; - memcpy(&c, &Cursor, sizeof(c)); + // PlcCursor c; + // memcpy(&c, &Cursor, sizeof(c)); - c.top -= ScrollYOffset*POS_HEIGHT*FONT_HEIGHT; - c.left -= ScrollXOffset; + // c.top -= ScrollYOffset*POS_HEIGHT*FONT_HEIGHT; + // c.left -= ScrollXOffset; - if(c.top >= IoListTop) return; + // if(c.top >= IoListTop) return; - if(c.top + c.height >= IoListTop) { - c.height = IoListTop - c.top - 3; - } + // if(c.top + c.height >= IoListTop) { + // c.height = IoListTop - c.top - 3; + // } - Hdc = GetDC(MainWindow); - SelectObject(Hdc, GetStockObject(WHITE_BRUSH)); - PatBlt(Hdc, c.left, c.top, c.width, c.height, PATINVERT); - CursorDrawn = !CursorDrawn; - ReleaseDC(MainWindow, Hdc); + // Hdc = GetDC(MainWindow); + // SelectObject(Hdc, GetStockObject(WHITE_BRUSH)); + // PatBlt(Hdc, c.left, c.top, c.width, c.height, PATINVERT); + // CursorDrawn = !CursorDrawn; + // ReleaseDC(MainWindow, Hdc); } //----------------------------------------------------------------------------- @@ -111,77 +111,77 @@ void CALLBACK BlinkCursor(HWND hwnd, UINT msg, UINT_PTR id, DWORD time) //----------------------------------------------------------------------------- static void DrawCharsToScreen(int cx, int cy, char *str) { - cy -= ScrollYOffset*POS_HEIGHT; - if(cy < -2) return; - if(cy*FONT_HEIGHT + Y_PADDING > IoListTop) return; - - COLORREF prev; - BOOL firstTime = TRUE; - BOOL inNumber = FALSE; - BOOL inComment = FALSE; - int inBrace = 0; - for(; *str; str++, cx++) { - int x = cx*FONT_WIDTH + X_PADDING; - int y = cy*FONT_HEIGHT + Y_PADDING; - - BOOL hiOk = !(InSimulationMode || ThisHighlighted); - - if(strchr("{}[]", *str) && hiOk && !inComment) { - if(*str == '{' || *str == '[') inBrace++; - if(inBrace == 1) { - prev = GetTextColor(Hdc); - SetTextColor(Hdc, HighlightColours.punct); - TextOut(Hdc, x, y, str, 1); - SetTextColor(Hdc, prev); - } else { - TextOut(Hdc, x, y, str, 1); - } - if(*str == ']' || *str == '}') inBrace--; - } else if(( - (isdigit(*str) && (firstTime || isspace(str[-1]) - || str[-1] == ':' || str[-1] == '[')) || - (*str == '-' && isdigit(str[1]))) && hiOk && !inComment) - { - prev = GetTextColor(Hdc); - SetTextColor(Hdc, HighlightColours.lit); - TextOut(Hdc, x, y, str, 1); - SetTextColor(Hdc, prev); - inNumber = TRUE; - } else if(*str == '\x01') { - cx--; - if(hiOk) { - prev = GetTextColor(Hdc); - SetTextColor(Hdc, HighlightColours.op); - } - } else if(*str == '\x02') { - cx--; - if(hiOk) { - SetTextColor(Hdc, prev); - inComment = FALSE; - } - } else if(*str == '\x03') { - cx--; - if(hiOk) { - prev = GetTextColor(Hdc); - SetTextColor(Hdc, HighlightColours.comment); - inComment = TRUE; - } - } else if(inNumber) { - if(isdigit(*str) || *str == '.') { - prev = GetTextColor(Hdc); - SetTextColor(Hdc, HighlightColours.lit); - TextOut(Hdc, x, y, str, 1); - SetTextColor(Hdc, prev); - } else { - TextOut(Hdc, x, y, str, 1); - inNumber = FALSE; - } - } else { - TextOut(Hdc, x, y, str, 1); - } - - firstTime = FALSE; - } + // cy -= ScrollYOffset*POS_HEIGHT; + // if(cy < -2) return; + // if(cy*FONT_HEIGHT + Y_PADDING > IoListTop) return; + + // COLORREF prev; + // BOOL firstTime = TRUE; + // BOOL inNumber = FALSE; + // BOOL inComment = FALSE; + // int inBrace = 0; + // for(; *str; str++, cx++) { + // int x = cx*FONT_WIDTH + X_PADDING; + // int y = cy*FONT_HEIGHT + Y_PADDING; + + // BOOL hiOk = !(InSimulationMode || ThisHighlighted); + + // if(strchr("{}[]", *str) && hiOk && !inComment) { + // if(*str == '{' || *str == '[') inBrace++; + // if(inBrace == 1) { + // prev = GetTextColor(Hdc); + // SetTextColor(Hdc, HighlightColours.punct); + // TextOut(Hdc, x, y, str, 1); + // SetTextColor(Hdc, prev); + // } else { + // TextOut(Hdc, x, y, str, 1); + // } + // if(*str == ']' || *str == '}') inBrace--; + // } else if(( + // (isdigit(*str) && (firstTime || isspace(str[-1]) + // || str[-1] == ':' || str[-1] == '[')) || + // (*str == '-' && isdigit(str[1]))) && hiOk && !inComment) + // { + // prev = GetTextColor(Hdc); + // SetTextColor(Hdc, HighlightColours.lit); + // TextOut(Hdc, x, y, str, 1); + // SetTextColor(Hdc, prev); + // inNumber = TRUE; + // } else if(*str == '\x01') { + // cx--; + // if(hiOk) { + // prev = GetTextColor(Hdc); + // SetTextColor(Hdc, HighlightColours.op); + // } + // } else if(*str == '\x02') { + // cx--; + // if(hiOk) { + // SetTextColor(Hdc, prev); + // inComment = FALSE; + // } + // } else if(*str == '\x03') { + // cx--; + // if(hiOk) { + // prev = GetTextColor(Hdc); + // SetTextColor(Hdc, HighlightColours.comment); + // inComment = TRUE; + // } + // } else if(inNumber) { + // if(isdigit(*str) || *str == '.') { + // prev = GetTextColor(Hdc); + // SetTextColor(Hdc, HighlightColours.lit); + // TextOut(Hdc, x, y, str, 1); + // SetTextColor(Hdc, prev); + // } else { + // TextOut(Hdc, x, y, str, 1); + // inNumber = FALSE; + // } + // } else { + // TextOut(Hdc, x, y, str, 1); + // } + + // firstTime = FALSE; + // } } //----------------------------------------------------------------------------- @@ -191,10 +191,10 @@ static void DrawCharsToScreen(int cx, int cy, char *str) //----------------------------------------------------------------------------- int ScreenColsAvailable(void) { - RECT r; - GetClientRect(MainWindow, &r); + // RECT r; + // GetClientRect(MainWindow, &r); - return (r.right - (X_PADDING + X_RIGHT_PADDING)) / (POS_WIDTH*FONT_WIDTH); + // return (r.right - (X_PADDING + X_RIGHT_PADDING)) / (POS_WIDTH*FONT_WIDTH); } //----------------------------------------------------------------------------- @@ -205,13 +205,13 @@ int ScreenColsAvailable(void) //----------------------------------------------------------------------------- int ScreenRowsAvailable(void) { - int adj; - if(ScrollXOffsetMax == 0) { - adj = 0; - } else { - adj = 18; - } - return (IoListTop - Y_PADDING - adj) / (POS_HEIGHT*FONT_HEIGHT); + // int adj; + // if(ScrollXOffsetMax == 0) { + // adj = 0; + // } else { + // adj = 18; + // } + // return (IoListTop - Y_PADDING - adj) / (POS_HEIGHT*FONT_HEIGHT); } //----------------------------------------------------------------------------- @@ -221,134 +221,134 @@ int ScreenRowsAvailable(void) //----------------------------------------------------------------------------- void PaintWindow(void) { - static HBITMAP BackBitmap; - static HDC BackDc; - static int BitmapWidth; - - ok(); - - RECT r; - GetClientRect(MainWindow, &r); - int bw = r.right; - int bh = IoListTop; - - HDC paintDc; - if(!BackDc) { - HWND desktop = GetDesktopWindow(); - RECT dk; - GetClientRect(desktop, &dk); - - BitmapWidth = max(2000, dk.right + 300); - BackBitmap = CreateCompatibleBitmap(Hdc, BitmapWidth, dk.bottom + 300); - BackDc = CreateCompatibleDC(Hdc); - SelectObject(BackDc, BackBitmap); - } - paintDc = Hdc; - Hdc = BackDc; - - RECT fi; - fi.left = 0; fi.top = 0; - fi.right = BitmapWidth; fi.bottom = bh; - FillRect(Hdc, &fi, InSimulationMode ? SimBgBrush : BgBrush); + // static HBITMAP BackBitmap; + // static HDC BackDc; + // static int BitmapWidth; + + // ok(); + + // RECT r; + // GetClientRect(MainWindow, &r); + // int bw = r.right; + // int bh = IoListTop; + + // HDC paintDc; + // if(!BackDc) { + // HWND desktop = GetDesktopWindow(); + // RECT dk; + // GetClientRect(desktop, &dk); + + // BitmapWidth = max(2000, dk.right + 300); + // BackBitmap = CreateCompatibleBitmap(Hdc, BitmapWidth, dk.bottom + 300); + // BackDc = CreateCompatibleDC(Hdc); + // SelectObject(BackDc, BackBitmap); + // } + // paintDc = Hdc; + // Hdc = BackDc; + + // RECT fi; + // fi.left = 0; fi.top = 0; + // fi.right = BitmapWidth; fi.bottom = bh; + // FillRect(Hdc, &fi, InSimulationMode ? SimBgBrush : BgBrush); - // now figure out how we should draw the ladder logic - ColsAvailable = ProgCountWidestRow(); - if(ColsAvailable < ScreenColsAvailable()) { - ColsAvailable = ScreenColsAvailable(); - } - memset(DisplayMatrix, 0, sizeof(DisplayMatrix)); - SelectionActive = FALSE; - memset(&Cursor, 0, sizeof(Cursor)); - - DrawChars = DrawCharsToScreen; - - int i; - int cy = 0; - int rowsAvailable = ScreenRowsAvailable(); - for(i = 0; i < Prog.numRungs; i++) { - int thisHeight = POS_HEIGHT*CountHeightOfElement(ELEM_SERIES_SUBCKT, - Prog.rungs[i]); - - // For speed, there is no need to draw everything all the time, but - // we still must draw a bit above and below so that the DisplayMatrix - // is filled in enough to make it possible to reselect using the - // cursor keys. - if(((cy + thisHeight) >= (ScrollYOffset - 8)*POS_HEIGHT) && - (cy < (ScrollYOffset + rowsAvailable + 8)*POS_HEIGHT)) - { - SetBkColor(Hdc, InSimulationMode ? HighlightColours.simBg : - HighlightColours.bg); - SetTextColor(Hdc, InSimulationMode ? HighlightColours.simRungNum : - HighlightColours.rungNum); - SelectObject(Hdc, FixedWidthFont); - int rung = i + 1; - int y = Y_PADDING + FONT_HEIGHT*cy; - int yp = y + FONT_HEIGHT*(POS_HEIGHT/2) - - POS_HEIGHT*FONT_HEIGHT*ScrollYOffset; - - if(rung < 10) { - char r[1] = { rung + '0' }; - TextOut(Hdc, 8 + FONT_WIDTH, yp, r, 1); - } else { - char r[2] = { (rung / 10) + '0', (rung % 10) + '0' }; - TextOut(Hdc, 8, yp, r, 2); - } - - int cx = 0; - DrawElement(ELEM_SERIES_SUBCKT, Prog.rungs[i], &cx, &cy, - Prog.rungPowered[i]); - } - - cy += thisHeight; - cy += POS_HEIGHT; - } - cy -= 2; - DrawEndRung(0, cy); - - if(SelectedGxAfterNextPaint >= 0) { - MoveCursorNear(SelectedGxAfterNextPaint, SelectedGyAfterNextPaint); - InvalidateRect(MainWindow, NULL, FALSE); - SelectedGxAfterNextPaint = -1; - SelectedGyAfterNextPaint = -1; - } else if(ScrollSelectedIntoViewAfterNextPaint && Selected) { - SelectElement(-1, -1, Selected->selectedState); - ScrollSelectedIntoViewAfterNextPaint = FALSE; - InvalidateRect(MainWindow, NULL, FALSE); - } else { - if(!SelectionActive) { - if(Prog.numRungs > 0) { - if(MoveCursorTopLeft()) { - InvalidateRect(MainWindow, NULL, FALSE); - } - } - } - } - - // draw the `buses' at either side of the screen - r.left = X_PADDING - FONT_WIDTH; - r.top = 0; - r.right = r.left + 4; - r.bottom = IoListTop; - FillRect(Hdc, &r, InSimulationMode ? BusLeftBrush : BusBrush); - - r.left += POS_WIDTH*FONT_WIDTH*ColsAvailable + 2; - r.right += POS_WIDTH*FONT_WIDTH*ColsAvailable + 2; - FillRect(Hdc, &r, InSimulationMode ? BusRightBus : BusBrush); + // // now figure out how we should draw the ladder logic + // ColsAvailable = ProgCountWidestRow(); + // if(ColsAvailable < ScreenColsAvailable()) { + // ColsAvailable = ScreenColsAvailable(); + // } + // memset(DisplayMatrix, 0, sizeof(DisplayMatrix)); + // SelectionActive = FALSE; + // memset(&Cursor, 0, sizeof(Cursor)); + + // DrawChars = DrawCharsToScreen; + + // int i; + // int cy = 0; + // int rowsAvailable = ScreenRowsAvailable(); + // for(i = 0; i < Prog.numRungs; i++) { + // int thisHeight = POS_HEIGHT*CountHeightOfElement(ELEM_SERIES_SUBCKT, + // Prog.rungs[i]); + + // // For speed, there is no need to draw everything all the time, but + // // we still must draw a bit above and below so that the DisplayMatrix + // // is filled in enough to make it possible to reselect using the + // // cursor keys. + // if(((cy + thisHeight) >= (ScrollYOffset - 8)*POS_HEIGHT) && + // (cy < (ScrollYOffset + rowsAvailable + 8)*POS_HEIGHT)) + // { + // SetBkColor(Hdc, InSimulationMode ? HighlightColours.simBg : + // HighlightColours.bg); + // SetTextColor(Hdc, InSimulationMode ? HighlightColours.simRungNum : + // HighlightColours.rungNum); + // SelectObject(Hdc, FixedWidthFont); + // int rung = i + 1; + // int y = Y_PADDING + FONT_HEIGHT*cy; + // int yp = y + FONT_HEIGHT*(POS_HEIGHT/2) - + // POS_HEIGHT*FONT_HEIGHT*ScrollYOffset; + + // if(rung < 10) { + // char r[1] = { rung + '0' }; + // TextOut(Hdc, 8 + FONT_WIDTH, yp, r, 1); + // } else { + // char r[2] = { (rung / 10) + '0', (rung % 10) + '0' }; + // TextOut(Hdc, 8, yp, r, 2); + // } + + // int cx = 0; + // DrawElement(ELEM_SERIES_SUBCKT, Prog.rungs[i], &cx, &cy, + // Prog.rungPowered[i]); + // } + + // cy += thisHeight; + // cy += POS_HEIGHT; + // } + // cy -= 2; + // DrawEndRung(0, cy); + + // if(SelectedGxAfterNextPaint >= 0) { + // MoveCursorNear(SelectedGxAfterNextPaint, SelectedGyAfterNextPaint); + // InvalidateRect(MainWindow, NULL, FALSE); + // SelectedGxAfterNextPaint = -1; + // SelectedGyAfterNextPaint = -1; + // } else if(ScrollSelectedIntoViewAfterNextPaint && Selected) { + // SelectElement(-1, -1, Selected->selectedState); + // ScrollSelectedIntoViewAfterNextPaint = FALSE; + // InvalidateRect(MainWindow, NULL, FALSE); + // } else { + // if(!SelectionActive) { + // if(Prog.numRungs > 0) { + // if(MoveCursorTopLeft()) { + // InvalidateRect(MainWindow, NULL, FALSE); + // } + // } + // } + // } + + // // draw the `buses' at either side of the screen + // r.left = X_PADDING - FONT_WIDTH; + // r.top = 0; + // r.right = r.left + 4; + // r.bottom = IoListTop; + // FillRect(Hdc, &r, InSimulationMode ? BusLeftBrush : BusBrush); + + // r.left += POS_WIDTH*FONT_WIDTH*ColsAvailable + 2; + // r.right += POS_WIDTH*FONT_WIDTH*ColsAvailable + 2; + // FillRect(Hdc, &r, InSimulationMode ? BusRightBus : BusBrush); - CursorDrawn = FALSE; + // CursorDrawn = FALSE; - BitBlt(paintDc, 0, 0, bw, bh, BackDc, ScrollXOffset, 0, SRCCOPY); + // BitBlt(paintDc, 0, 0, bw, bh, BackDc, ScrollXOffset, 0, SRCCOPY); - if(InSimulationMode) { - KillTimer(MainWindow, TIMER_BLINK_CURSOR); - } else { - KillTimer(MainWindow, TIMER_BLINK_CURSOR); - BlinkCursor(NULL, 0, NULL, 0); - SetTimer(MainWindow, TIMER_BLINK_CURSOR, 800, BlinkCursor); - } + // if(InSimulationMode) { + // KillTimer(MainWindow, TIMER_BLINK_CURSOR); + // } else { + // KillTimer(MainWindow, TIMER_BLINK_CURSOR); + // BlinkCursor(NULL, 0, NULL, 0); + // SetTimer(MainWindow, TIMER_BLINK_CURSOR, 800, BlinkCursor); + // } - Hdc = paintDc; - ok(); + // Hdc = paintDc; + // ok(); } //----------------------------------------------------------------------------- @@ -390,52 +390,52 @@ static void SetSyntaxHighlightingColours(void) //----------------------------------------------------------------------------- void InitForDrawing(void) { - SetSyntaxHighlightingColours(); - - FixedWidthFont = CreateFont( - FONT_HEIGHT, FONT_WIDTH, - 0, 0, - FW_REGULAR, - FALSE, - FALSE, - FALSE, - ANSI_CHARSET, - OUT_DEFAULT_PRECIS, - CLIP_DEFAULT_PRECIS, - DEFAULT_QUALITY, - FF_DONTCARE, - "Lucida Console"); - - FixedWidthFontBold = CreateFont( - FONT_HEIGHT, FONT_WIDTH, - 0, 0, - FW_REGULAR, // the bold text renders funny under Vista - FALSE, - FALSE, - FALSE, - ANSI_CHARSET, - OUT_DEFAULT_PRECIS, - CLIP_DEFAULT_PRECIS, - DEFAULT_QUALITY, - FF_DONTCARE, - "Lucida Console"); - - LOGBRUSH lb; - lb.lbStyle = BS_SOLID; - lb.lbColor = HighlightColours.simBusRight; - BusRightBus = CreateBrushIndirect(&lb); - - lb.lbColor = HighlightColours.simBusLeft; - BusLeftBrush = CreateBrushIndirect(&lb); - - lb.lbColor = HighlightColours.bus; - BusBrush = CreateBrushIndirect(&lb); - - lb.lbColor = HighlightColours.bg; - BgBrush = CreateBrushIndirect(&lb); - - lb.lbColor = HighlightColours.simBg; - SimBgBrush = CreateBrushIndirect(&lb); + // SetSyntaxHighlightingColours(); + + // FixedWidthFont = CreateFont( + // FONT_HEIGHT, FONT_WIDTH, + // 0, 0, + // FW_REGULAR, + // FALSE, + // FALSE, + // FALSE, + // ANSI_CHARSET, + // OUT_DEFAULT_PRECIS, + // CLIP_DEFAULT_PRECIS, + // DEFAULT_QUALITY, + // FF_DONTCARE, + // "Lucida Console"); + + // FixedWidthFontBold = CreateFont( + // FONT_HEIGHT, FONT_WIDTH, + // 0, 0, + // FW_REGULAR, // the bold text renders funny under Vista + // FALSE, + // FALSE, + // FALSE, + // ANSI_CHARSET, + // OUT_DEFAULT_PRECIS, + // CLIP_DEFAULT_PRECIS, + // DEFAULT_QUALITY, + // FF_DONTCARE, + // "Lucida Console"); + + // LOGBRUSH lb; + // lb.lbStyle = BS_SOLID; + // lb.lbColor = HighlightColours.simBusRight; + // BusRightBus = CreateBrushIndirect(&lb); + + // lb.lbColor = HighlightColours.simBusLeft; + // BusLeftBrush = CreateBrushIndirect(&lb); + + // lb.lbColor = HighlightColours.bus; + // BusBrush = CreateBrushIndirect(&lb); + + // lb.lbColor = HighlightColours.bg; + // BgBrush = CreateBrushIndirect(&lb); + + // lb.lbColor = HighlightColours.simBg; + // SimBgBrush = CreateBrushIndirect(&lb); } //----------------------------------------------------------------------------- @@ -458,105 +458,105 @@ static void DrawCharsToExportBuffer(int cx, int cy, char *str) //----------------------------------------------------------------------------- void ExportDrawingAsText(char *file) { - int maxWidth = ProgCountWidestRow(); - ColsAvailable = maxWidth; - - int totalHeight = 0; - int i; - for(i = 0; i < Prog.numRungs; i++) { - totalHeight += CountHeightOfElement(ELEM_SERIES_SUBCKT, Prog.rungs[i]); - totalHeight += 1; - } - totalHeight *= POS_HEIGHT; - totalHeight += 3; - - ExportBuffer = (char **)CheckMalloc(totalHeight * sizeof(char *)); + // int maxWidth = ProgCountWidestRow(); + // ColsAvailable = maxWidth; + + // int totalHeight = 0; + // int i; + // for(i = 0; i < Prog.numRungs; i++) { + // totalHeight += CountHeightOfElement(ELEM_SERIES_SUBCKT, Prog.rungs[i]); + // totalHeight += 1; + // } + // totalHeight *= POS_HEIGHT; + // totalHeight += 3; + + // ExportBuffer = (char **)CheckMalloc(totalHeight * sizeof(char *)); - int l = maxWidth*POS_WIDTH + 8; - for(i = 0; i < totalHeight; i++) { - ExportBuffer[i] = (char *)CheckMalloc(l); - memset(ExportBuffer[i], ' ', l-1); - ExportBuffer[i][4] = '|'; - ExportBuffer[i][3] = '|'; - ExportBuffer[i][l-3] = '|'; - ExportBuffer[i][l-2] = '|'; - ExportBuffer[i][l-1] = '\0'; - } - - DrawChars = DrawCharsToExportBuffer; - - int cy = 1; - for(i = 0; i < Prog.numRungs; i++) { - int cx = 5; - DrawElement(ELEM_SERIES_SUBCKT, Prog.rungs[i], &cx, &cy, - Prog.rungPowered[i]); - - if((i + 1) < 10) { - ExportBuffer[cy+1][1] = '0' + (i + 1); - } else { - ExportBuffer[cy+1][1] = '0' + ((i + 1) % 10); - ExportBuffer[cy+1][0] = '0' + ((i + 1) / 10); - } - - cy += POS_HEIGHT*CountHeightOfElement(ELEM_SERIES_SUBCKT, - Prog.rungs[i]); - cy += POS_HEIGHT; - } - cy -= 2; - DrawEndRung(5, cy); - - FILE *f = fopen(file, "w"); - if(!f) { - Error(_("Couldn't open '%s'\n"), f); - return; - } - - fprintf(f, "LDmicro export text\n"); - - if(Prog.mcu) { - fprintf(f, "for '%s', %.6f MHz crystal, %.1f ms cycle time\n\n", - Prog.mcu->mcuName, Prog.mcuClock/1e6, Prog.cycleTime/1e3); - } else { - fprintf(f, "no MCU assigned, %.6f MHz crystal, %.1f ms cycle time\n\n", - Prog.mcuClock/1e6, Prog.cycleTime/1e3); - } - - fprintf(f, "\nLADDER DIAGRAM:\n\n"); - - for(i = 0; i < totalHeight; i++) { - ExportBuffer[i][4] = '|'; - fprintf(f, "%s\n", ExportBuffer[i]); - CheckFree(ExportBuffer[i]); - } - CheckFree(ExportBuffer); - ExportBuffer = NULL; - - fprintf(f, _("\n\nI/O ASSIGNMENT:\n\n")); + // int l = maxWidth*POS_WIDTH + 8; + // for(i = 0; i < totalHeight; i++) { + // ExportBuffer[i] = (char *)CheckMalloc(l); + // memset(ExportBuffer[i], ' ', l-1); + // ExportBuffer[i][4] = '|'; + // ExportBuffer[i][3] = '|'; + // ExportBuffer[i][l-3] = '|'; + // ExportBuffer[i][l-2] = '|'; + // ExportBuffer[i][l-1] = '\0'; + // } + + // DrawChars = DrawCharsToExportBuffer; + + // int cy = 1; + // for(i = 0; i < Prog.numRungs; i++) { + // int cx = 5; + // DrawElement(ELEM_SERIES_SUBCKT, Prog.rungs[i], &cx, &cy, + // Prog.rungPowered[i]); + + // if((i + 1) < 10) { + // ExportBuffer[cy+1][1] = '0' + (i + 1); + // } else { + // ExportBuffer[cy+1][1] = '0' + ((i + 1) % 10); + // ExportBuffer[cy+1][0] = '0' + ((i + 1) / 10); + // } + + // cy += POS_HEIGHT*CountHeightOfElement(ELEM_SERIES_SUBCKT, + // Prog.rungs[i]); + // cy += POS_HEIGHT; + // } + // cy -= 2; + // DrawEndRung(5, cy); + + // FILE *f = fopen(file, "w"); + // if(!f) { + // Error(_("Couldn't open '%s'\n"), f); + // return; + // } + + // fprintf(f, "LDmicro export text\n"); + + // if(Prog.mcu) { + // fprintf(f, "for '%s', %.6f MHz crystal, %.1f ms cycle time\n\n", + // Prog.mcu->mcuName, Prog.mcuClock/1e6, Prog.cycleTime/1e3); + // } else { + // fprintf(f, "no MCU assigned, %.6f MHz crystal, %.1f ms cycle time\n\n", + // Prog.mcuClock/1e6, Prog.cycleTime/1e3); + // } + + // fprintf(f, "\nLADDER DIAGRAM:\n\n"); + + // for(i = 0; i < totalHeight; i++) { + // ExportBuffer[i][4] = '|'; + // fprintf(f, "%s\n", ExportBuffer[i]); + // CheckFree(ExportBuffer[i]); + // } + // CheckFree(ExportBuffer); + // ExportBuffer = NULL; + + // fprintf(f, _("\n\nI/O ASSIGNMENT:\n\n")); - fprintf(f, _(" Name | Type | Pin\n")); - fprintf(f, " ----------------------------+--------------------+------\n"); - for(i = 0; i < Prog.io.count; i++) { - char b[1024]; - memset(b, '\0', sizeof(b)); + // fprintf(f, _(" Name | Type | Pin\n")); + // fprintf(f, " ----------------------------+--------------------+------\n"); + // for(i = 0; i < Prog.io.count; i++) { + // char b[1024]; + // memset(b, '\0', sizeof(b)); - PlcProgramSingleIo *io = &Prog.io.assignment[i]; - char *type = IoTypeToString(io->type); - char pin[MAX_NAME_LEN]; + // PlcProgramSingleIo *io = &Prog.io.assignment[i]; + // char *type = IoTypeToString(io->type); + // char pin[MAX_NAME_LEN]; - PinNumberForIo(pin, io); + // PinNumberForIo(pin, io); - sprintf(b, " | | %s\n", - pin); + // sprintf(b, " | | %s\n", + // pin); - memcpy(b+2, io->name, strlen(io->name)); - memcpy(b+31, type, strlen(type)); - fprintf(f, "%s", b); - } + // memcpy(b+2, io->name, strlen(io->name)); + // memcpy(b+31, type, strlen(type)); + // fprintf(f, "%s", b); + // } - fclose(f); + // fclose(f); - // we may have trashed the grid tables a bit; a repaint will fix that - InvalidateRect(MainWindow, NULL, FALSE); + // // we may have trashed the grid tables a bit; a repaint will fix that + // InvalidateRect(MainWindow, NULL, FALSE); } //----------------------------------------------------------------------------- @@ -565,46 +565,46 @@ void ExportDrawingAsText(char *file) //----------------------------------------------------------------------------- void SetUpScrollbars(BOOL *horizShown, SCROLLINFO *horiz, SCROLLINFO *vert) { - int totalHeight = 0; - int i; - for(i = 0; i < Prog.numRungs; i++) { - totalHeight += CountHeightOfElement(ELEM_SERIES_SUBCKT, Prog.rungs[i]); - totalHeight++; - } - totalHeight += 1; // for the end rung - - int totalWidth = ProgCountWidestRow(); - - if(totalWidth <= ScreenColsAvailable()) { - *horizShown = FALSE; - ScrollXOffset = 0; - ScrollXOffsetMax = 0; - } else { - *horizShown = TRUE; - memset(horiz, 0, sizeof(*horiz)); - horiz->cbSize = sizeof(*horiz); - horiz->fMask = SIF_DISABLENOSCROLL | SIF_ALL; - horiz->nMin = 0; - horiz->nMax = X_PADDING + totalWidth*POS_WIDTH*FONT_WIDTH; - RECT r; - GetClientRect(MainWindow, &r); - horiz->nPage = r.right - X_PADDING; - horiz->nPos = ScrollXOffset; - - ScrollXOffsetMax = horiz->nMax - horiz->nPage + 1; - if(ScrollXOffset > ScrollXOffsetMax) ScrollXOffset = ScrollXOffsetMax; - if(ScrollXOffset < 0) ScrollXOffset = 0; - } - - vert->cbSize = sizeof(*vert); - vert->fMask = SIF_DISABLENOSCROLL | SIF_ALL; - vert->nMin = 0; - vert->nMax = totalHeight - 1; - vert->nPos = ScrollYOffset; - vert->nPage = ScreenRowsAvailable(); - - ScrollYOffsetMax = vert->nMax - vert->nPage + 1; - - if(ScrollYOffset > ScrollYOffsetMax) ScrollYOffset = ScrollYOffsetMax; - if(ScrollYOffset < 0) ScrollYOffset = 0; + // int totalHeight = 0; + // int i; + // for(i = 0; i < Prog.numRungs; i++) { + // totalHeight += CountHeightOfElement(ELEM_SERIES_SUBCKT, Prog.rungs[i]); + // totalHeight++; + // } + // totalHeight += 1; // for the end rung + + // int totalWidth = ProgCountWidestRow(); + + // if(totalWidth <= ScreenColsAvailable()) { + // *horizShown = FALSE; + // ScrollXOffset = 0; + // ScrollXOffsetMax = 0; + // } else { + // *horizShown = TRUE; + // memset(horiz, 0, sizeof(*horiz)); + // horiz->cbSize = sizeof(*horiz); + // horiz->fMask = SIF_DISABLENOSCROLL | SIF_ALL; + // horiz->nMin = 0; + // horiz->nMax = X_PADDING + totalWidth*POS_WIDTH*FONT_WIDTH; + // RECT r; + // GetClientRect(MainWindow, &r); + // horiz->nPage = r.right - X_PADDING; + // horiz->nPos = ScrollXOffset; + + // ScrollXOffsetMax = horiz->nMax - horiz->nPage + 1; + // if(ScrollXOffset > ScrollXOffsetMax) ScrollXOffset = ScrollXOffsetMax; + // if(ScrollXOffset < 0) ScrollXOffset = 0; + // } + + // vert->cbSize = sizeof(*vert); + // vert->fMask = SIF_DISABLENOSCROLL | SIF_ALL; + // vert->nMin = 0; + // vert->nMax = totalHeight - 1; + // vert->nPos = ScrollYOffset; + // vert->nPage = ScreenRowsAvailable(); + + // ScrollYOffsetMax = vert->nMax - vert->nPage + 1; + + // if(ScrollYOffset > ScrollYOffsetMax) ScrollYOffset = ScrollYOffsetMax; + // if(ScrollYOffset < 0) ScrollYOffset = 0; } diff --git a/ldmicro/helpdialog.cpp b/ldmicro/helpdialog.cpp index 9ac82af..cf23caa 100644 --- a/ldmicro/helpdialog.cpp +++ b/ldmicro/helpdialog.cpp @@ -23,10 +23,10 @@ // colours. // Jonathan Westhues, Dec 2004 //----------------------------------------------------------------------------- -#include <windows.h> +#include "linuxUI.h" #include <stdio.h> #include <stdlib.h> -#include <commctrl.h> +//#include <commctrl.h> #include <richedit.h> #include "ldmicro.h" diff --git a/ldmicro/img/dpdt_1.png b/ldmicro/img/dpdt_1.png Binary files differdeleted file mode 100644 index 17ff18d..0000000 --- a/ldmicro/img/dpdt_1.png +++ /dev/null diff --git a/ldmicro/img/dpdt_2.png b/ldmicro/img/dpdt_2.png Binary files differdeleted file mode 100644 index 56c61a8..0000000 --- a/ldmicro/img/dpdt_2.png +++ /dev/null diff --git a/ldmicro/img/dpst_1.png b/ldmicro/img/dpst_1.png Binary files differdeleted file mode 100644 index 38a58ac..0000000 --- a/ldmicro/img/dpst_1.png +++ /dev/null diff --git a/ldmicro/img/dpst_2.png b/ldmicro/img/dpst_2.png Binary files differdeleted file mode 100644 index 6e254c8..0000000 --- a/ldmicro/img/dpst_2.png +++ /dev/null diff --git a/ldmicro/img/relay_nc.png b/ldmicro/img/relay_nc.png Binary files differdeleted file mode 100644 index 25c6f66..0000000 --- a/ldmicro/img/relay_nc.png +++ /dev/null diff --git a/ldmicro/img/relay_no.png b/ldmicro/img/relay_no.png Binary files differdeleted file mode 100644 index c1739d4..0000000 --- a/ldmicro/img/relay_no.png +++ /dev/null diff --git a/ldmicro/img/spdt_1.png b/ldmicro/img/spdt_1.png Binary files differdeleted file mode 100644 index 5141923..0000000 --- a/ldmicro/img/spdt_1.png +++ /dev/null diff --git a/ldmicro/img/spdt_2.png b/ldmicro/img/spdt_2.png Binary files differdeleted file mode 100644 index 9132841..0000000 --- a/ldmicro/img/spdt_2.png +++ /dev/null diff --git a/ldmicro/img/switch_connected.png b/ldmicro/img/switch_connected.png Binary files differdeleted file mode 100644 index 6aa84b4..0000000 --- a/ldmicro/img/switch_connected.png +++ /dev/null diff --git a/ldmicro/img/switch_disconnected.png b/ldmicro/img/switch_disconnected.png Binary files differdeleted file mode 100644 index 596c939..0000000 --- a/ldmicro/img/switch_disconnected.png +++ /dev/null diff --git a/ldmicro/includes/advanceddialog.h b/ldmicro/includes/advanceddialog.h deleted file mode 100644 index 5e4808f..0000000 --- a/ldmicro/includes/advanceddialog.h +++ /dev/null @@ -1,142 +0,0 @@ -#ifndef _ADVANCED_DIALOG_H -#define _ADVANCED_DIALOG_H - -#define MAX_PIN_NAME 128 - -/*Advanced Dialog Menus*/ -#define MNU_ADV_NEW 0x01 -#define MNU_ADV_OPEN 0x02 -#define MNU_ADV_SAVE 0x03 -#define MNU_ADV_SAVE_AS 0x04 -#define MNU_ADV_EXIT 0x05 - -#define MNU_ADV_UNDO 0x10 -#define MNU_ADV_REDO 0x11 -#define MNU_ADV_CUT 0x12 -#define MNU_ADV_COPY 0x13 -#define MNU_ADV_PASTE 0x14 -#define MNU_ADV_DEL 0x15 - -#define MNU_ADV_SIMULATION_MODE 0x20 -#define MNU_ADV_START_SIMULATION 0x21 -#define MNU_ADV_STOP_SIMULATION 0x22 -#define MNU_ADV_SINGLE_CYCLE 0x23 - -#define MNU_ADV_MANUAL 0x30 -#define MNU_ADV_ABOUT 0x31 - -#define MAX_NAME_LENGTH 128 -#define MAX_SCREEN_ITEMS 512 -#define MAX_PINS 4000 -#define MCU_PIN_FLAG 4000 -#define MAX_MCU_PINS 128 -#define TIMER_ADV_SIMULATE 101 - - -typedef struct ImageStructTag { - int selectedState; - HIMAGELIST Images; - int ComponentId; -} ImageStruct; - -typedef struct ImageLocationTag{ - int Id; - ImageStruct* Image; - int Index; - int x; - int y; - void* Properties; - void* PinId; - void* PinName; -}ImageLocation; - -typedef struct PinInfoTag{ - double Volt; - double OperatingVolt; - void** ImageId; - int* Index; - int* ImageType; //To compare with imagelocation array - int LinkCount; //No of valid entries in array - double ProgVolt; - void* ProgComponent; -}PinInfo; - -typedef struct PinMcuTag{ - UINT PinId; - UINT state; - int type; - BOOL InternalPullup; -}PinMcu; - -typedef struct PinNameTag{ - UINT PinId; //Need to generate unique pinid every time user saves a name - TCHAR Name[MAX_NAME_LENGTH]; - PinInfo PinData; -}PinName; - -typedef struct PinComponentTag{ - UINT PinId; - void** ComponentAddress; - int Count; - void* Next; -}PinComponent; - -extern HANDLE ImageHeap; -extern HFONT AdvNiceFont; -extern HFONT AdvFixedFont; -extern UINT NameCount; -extern ImageLocation ImageStack[MAX_SCREEN_ITEMS]; -// extern PinInfo PinData[MAX_PINS]; -extern PinMcu McuPin[MAX_MCU_PINS]; -extern PinName NameId[MAX_PINS]; -extern HWND AdvancedDialog; -extern PinComponent ComponentPin; - -/*Advanced Dialog Functions*/ -void MakeAdvancedDialogControls(void); -void AdvancedDialogResized(void); -void MakeAdvancedWindowMenus(void); -void ProcessEvent(int x, int y, int Event); -void AdvancedWindowClosing(void); -void ToggleAdvancedSimulationMode(void); -void SimulateOneAdvCycle(BOOL ForceRefresh); -int IsMCUPin(int PinId); -// void CreateVoltRequest(int PinId, int Index, double VoltReq); - -// Heap Functions -void* AllocImageHeap(size_t n); -void* ReallocImageHeap(LPVOID lpMem, size_t n); -void FreeImageHeap(void *p); - -// Component Functions - -void InitComponents(void); - -double GetGlobalVoltage(int PinId, void* ComponentAddress); -double RefreshVolt(int PinId, int Index, UINT Id, void* ComponentAddress, double volt); -double RefreshProcessorStat(int PinId, UINT Id); - - -int RegisterPinName(LPCTSTR Name); -int SetPinImage(int PinId,void* ImageId,int ImageType, int Index); -int FlushPinNames(void); //Clear Pins which are deleted from MainWindow -int DeRegisterPinName(LPCTSTR Name, void* ImageId); -int DeletePinImage(LPCTSTR Name, void* ImageId, int Index); -int DeletePinName(UINT Index); -void SetMcu(int PinId, int Type); -void RefreshNamingList(void); -void PopulateNamingList(void); - -double RequestVoltChange(int PinId, int Index, void *ComponentAddress, double volt); - -int DeleteComponentPin(int PinId, void* ComponentAddress); -int AddComponentPin(int PinId, void* ComponentAddress); -// int RegisterPinState(int Index, double Volt); - -//NamingList functions -void ToggleInternalPullup(int PinId); - - -extern BOOL SimulationStarted; - -#endif diff --git a/ldmicro/includes/componentlist.h b/ldmicro/includes/componentlist.h deleted file mode 100644 index 20c095b..0000000 --- a/ldmicro/includes/componentlist.h +++ /dev/null @@ -1,71 +0,0 @@ -//----------------------------------------------------------------------------- -// Copyright 2007 Jonathan Westhues -// -// This file is part of LDmicro. -// -// LDmicro is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// LDmicro is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with LDmicro. If not, see <http://www.gnu.org/licenses/>. -//------ -// -// Constants, structures, declarations etc. for the PIC ladder logic compiler -// Jonathan Westhues, Oct 2004 -//----------------------------------------------------------------------------- - -#ifndef __COMPONENTLIST_H -#define __COMPONENTLIST_H - -#define MAX_COMPONENTS 999 -#define MAX_IMAGES 10 - -#define COMPONENT_WIDTH 100 -#define COMPONENT_HEIGHT 100 - -extern HDC HdcMem; -extern HWND ComponentList; -extern HBITMAP test; -extern HIMAGELIST ComponentDiagrams; -extern HWND AdvancedWorkspace; -extern BOOL Dragging; -extern int ImagesDrawn; -extern int DragX; -extern int DragY; -extern UINT UniquePinId; -extern UINT UniqueImgId; - - -/*map<int, HIMAGELIST, int, int, int> Imagemap; //To relate image with it's drawing area(Index,Images,x,y,maptype) -map<int, BOOL, BOOL, BOOL> Switchmap; //Add MCU pin later //(Index(same as Imagemap), Selected, Default Connected,Latch Action) -map<int, BOOL> Relaymap; //Add MCU pin later //(Index(same as Imagemap), Selected) - -extern Imagemap test;*/ - -void ComponentListProc(NMHDR *h); -void ComponentListInitiate(void); - -void InitializeImageList(HIMAGELIST *il); - -int BeginComponentDrag(int x, int y); -int ComponentDrag(int x, int y); -int EndComponentDrag(int x, int y); - -// Componentimages.cpp functions -//Function Definitions - -void InitializeComponentImage(int Component, HIMAGELIST *il); -IStream * CreateStreamOnResource(LPCTSTR lpName, LPCTSTR lpType); -IWICBitmapSource * LoadBitmapFromStream(IStream * ipImageStream); -HBITMAP CreateHBITMAP(IWICBitmapSource * ipBitmap); -HBITMAP LoadComponentImage(int resource); - - -#endif
\ No newline at end of file diff --git a/ldmicro/includes/components/componentfunctions.h b/ldmicro/includes/components/componentfunctions.h deleted file mode 100644 index 916bf00..0000000 --- a/ldmicro/includes/components/componentfunctions.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef _COMPONENT_FUNCTIONS -#define _COMPONENT_FUNCTIONS - -//Few Prerequisites -extern HFONT MyNiceFont; -extern HFONT MyFixedFont; -extern HWND OkButton; -extern HWND CancelButton; -extern HINSTANCE* ComponentInstance; - -extern BOOL DlgDone; -extern BOOL DlgCancel; -extern HWND ComponentDialog; - -// Common Functions - -void FontNice(HWND h); -void FontFixed(HWND h); -HWND* CreateDialogWindow(LPCTSTR title, int x, int y, int width, int height, int style); -void ShowDialogWindow(void); -BOOL ProcessDialogWindow(void); - -/*Initialization Functions*/ -int InitSwitch(void* ComponentAddress); -int InitRelay(void* ComponentAddress); -int InitSpdt(void* ComponentAddress); -int InitDpst(void* ComponentAddress); -int InitDpdt(void* ComponentAddress); - -/*Event Handlers*/ -void HandleSwitchEvent(void* ComponentAddress, int Event, BOOL SimulationStarted, - void* ImageLocation, UINT ImageId, HWND* h); -void HandleRelayEvent(void* ComponentAddress, int Event, BOOL SimulationStarted, - void* ImageLocation, UINT ImageId, HWND* h); -void HandleSpdtEvent(void* ComponentAddress, int Event, BOOL SimulationStarted, - void* ImageLocation, UINT ImageId, HWND* h); -void HandleDpstEvent(void* ComponentAddress, int Event, BOOL SimulationStarted, - void* ImageLocation, UINT ImageId, HWND* h); -void HandleDpdtEvent(void* ComponentAddress, int Event, BOOL SimulationStarted, - void* ImageLocation, UINT ImageId, HWND* h); - -/*Request Handlers*/ -double SwitchVoltChanged(void* ComponentAddress, BOOL SimulationStarted, int index, - double Volt, int Source, void* ImageLocation); -double RelayVoltChanged(void* ComponentAddress, BOOL SimulationStarted, int index, - double Volt, int Source, void* ImageLocation); -double SpdtVoltChanged(void* ComponentAddress, BOOL SimulationStarted, int index, - double Volt, int Source, void* ImageLocation); -double DpstVoltChanged(void* ComponentAddress, BOOL SimulationStarted, int index, - double Volt, int Source, void* ImageLocation); -double DpdtVoltChanged(void* ComponentAddress, BOOL SimulationStarted, int index, - double Volt, int Source, void* ImageLocation); - -/*Program Reference Functions*/ -void SetSwitchIds(int*, void*); -void SetRelayIds(int*, void*); -void SetSpdtIds(int*, void*); -void SetDpstIds(int*, void*); -void SetDpdtIds(int*, void*); - -// Relay Functions - -#endif diff --git a/ldmicro/includes/components/componentimages.h b/ldmicro/includes/components/componentimages.h deleted file mode 100644 index 27ef6ce..0000000 --- a/ldmicro/includes/components/componentimages.h +++ /dev/null @@ -1,53 +0,0 @@ -#ifndef __COMPONENTIMAGES_H -#define __COMPONENTIMAGES_H - -#define SWITCH_CONNECTED 8000 -#define SWITCH_DISCONNECTED 8001 -#define RELAY_NC 8002 -#define RELAY_NO 8003 -#define SPDT_1 8004 -#define SPDT_2 8005 -#define DPST_1 8006 -#define DPST_2 8007 -#define DPDT_1 8008 -#define DPDT_2 8009 - - - -#ifndef RC_INVOKED //Used to hide code from resource file(Guess) - -#define TOTAL_COMPONENTS 5 -#define COMPONENT_NAME_MAX_LENGTH 50 - -// Try to keep ComponentID's between 6000 - 6999 - -#define COMPONENT_SWITCH 6000 -#define COMPONENT_RELAY 6001 -#define COMPONENT_SPDT 6002 -#define COMPONENT_DPST 6003 -#define COMPONENT_DPDT 6004 - - -#define MAX_PIN_COUNT 10 - -typedef struct ComponentDataTag{ - int Index; - int ComponentId; - TCHAR ComponentName[COMPONENT_NAME_MAX_LENGTH]; - int PinCount; - LPCTSTR PinNames[MAX_PIN_COUNT]; //Valid Number of images from below property -}ComponentData; - -void RefreshImages(); -void SetImage(int Component, void *il); - -static ComponentData rgCompData[TOTAL_COMPONENTS] = { - {0, COMPONENT_SWITCH, TEXT("Switch"), 2, {"Input:", "Output:"}}, - {1, COMPONENT_RELAY, TEXT("Relay"), 5, {"Coil1:", "Coil2:", "NO:", "COM:", "NC:"}}, - {2, COMPONENT_SPDT, TEXT("SPDT"), 3, {"Input:", "Output1:", "Output2:"}}, - {3, COMPONENT_DPST, TEXT("DPST"), 4, {"Input1:", "Input2:", "Output1:", "Output2:"}}, - {4, COMPONENT_DPDT, TEXT("DPDT"), 6, {"Input1:", "Input2:", "Output11:", "Output12:", "Output21:", "Output22:"}} -}; - -#endif -#endif diff --git a/ldmicro/includes/components/components.h b/ldmicro/includes/components/components.h deleted file mode 100644 index 810c2d2..0000000 --- a/ldmicro/includes/components/components.h +++ /dev/null @@ -1,51 +0,0 @@ -#ifndef _COMPONENTS_H -#define _COMPONENTS_H - -#define EVENT_VALUE_CHANGED 0 -#define EVENT_MOUSE_CLICK 1 -#define EVENT_MOUSE_DOWN 2 -#define EVENT_MOUSE_UP 3 -#define EVENT_MOUSE_RDOWN 4 -#define EVENT_MOUSE_RUP 5 -#define EVENT_MOUSE_DBLCLICK 6 -#define EVENT_MOUSE_RCLICK 7 - - - -#define SOURCE_PROGRAM_MAIN 1 -#define SOURCE_PROGRAM_NEW 2 -#define SOURCE_EVENT_MAIN 3 -#define SOURCE_EVENT_NEW 4 -#define SOURCE_FORCE_MAIN 5 -#define SOURCE_REQUEST_MAIN 6 - -/*#define EVENT_KEY_DOWN 6 -#define EVENT_KEY_RELEASE 7 -#define EVENT_KEY_PRESS 8*/ -#define V_DIALOG_WIDTH 96 -#define V_DIALOG_HEIGHT 115 -#define H_DIALOG_WIDTH 179 -#define H_DIALOG_HEIGHT 85 - -//Window styles for dialog box -#define STYLE_HORIZONTAL 1 -#define STYLE_VERTICAL 2 - -#define GND 0 -#define VOLT_5 5 -#define V_OPEN 4196 - -int NotifyComponent(void *ComponentAddress, void* PinName, int ComponentId, int Event, - BOOL SimulationStarted, HWND* h, int Index, UINT ImageId, void* ImageLocation); -int InitializeComponentProperties(void *ComponentAddress, int ComponentId); -double VoltSet(void* ComponentAddress, BOOL SimulationStarted, int ImageType, int Index, - double Volt, int Source, void* ImageLocation); - -double VoltRequest(int PinId, void* ComponentAddress); -// void RequestData(void* ComponentAddress); -// double GlobalVoltChange(int PinId, void *ComponentAddress, double volt); -double VoltChange(int PinId, int Index, void* ComponentAddress, double Volt); -size_t GetStructSize(int ComponentId); -size_t GetNameSize(int ComponentId); - -#endif diff --git a/ldmicro/includes/components/componentstructs.h b/ldmicro/includes/components/componentstructs.h deleted file mode 100644 index 76dadda..0000000 --- a/ldmicro/includes/components/componentstructs.h +++ /dev/null @@ -1,62 +0,0 @@ -#ifndef _COMPONENT_STRUCTS -#define _COMPONENT_STRUCTS - -typedef struct SwitchStructTag -{ - int id; - int Image; - BOOL Latched; //Temporary/Latched Action - BOOL NOpen; //Initial Open/Closed position - BOOL Open; - char Name[15]; - double Volt[2]; - int PinId[2]; -}SwitchStruct; - -typedef struct RelayStructTag -{ - int id; - int Image; - BOOL NC; //Whether relay is operated - double MinOperatingVolt; //Operating voltage - double MaxOperatingVolt; - double CoilVolt1; //Voltage at input pin - double CoilVolt2; //Voltage at input pin - double COMVolt; //Voltage at COM pin - double NOVolt; //Voltage at NO pin - double NCVolt; //Voltage at NC pin - int PinId[5]; - -}RelayStruct; - -typedef struct SpdtStructTag -{ - int id; - int image; - BOOL latched; //Whether the swetch is in latch mode or not - BOOL NO1; //Whether Output 1 is connected - double Volt[3]; //Voltage at Input, Output1, Output2 respectively - int PinId[3]; -}SpdtStruct; - -typedef struct DpstStructTag -{ - int id; - int image; - BOOL latched; //Whether the swetch is in latch mode or not - BOOL NO; //Whether the inputs and outputs are disconnected (Open) - double Volt[4]; // Voltage at Input1, Input2, Output1, Output2 respectively - int PinId[4]; -}DpstStruct; - -typedef struct DpdtStructTag -{ - int id; - int image; - BOOL latched; //Whether the swetch is in latch mode or not - BOOL NS1; //Whether the inputs and outputs are connected in state 1 - double Volt[6]; // Voltage at Input1, Input2, Output11, Output12, Output21, Output22 respectively - int PinId[6]; -}DpdtStruct; - -#endif diff --git a/ldmicro/includes/ldmicro.h b/ldmicro/includes/ldmicro.h index e434b82..caa154d 100644 --- a/ldmicro/includes/ldmicro.h +++ b/ldmicro/includes/ldmicro.h @@ -501,27 +501,26 @@ typedef struct McuIoInfoTag { #define NUM_SUPPORTED_MCUS 16 -/* //----------------------------------------------- // Function prototypes // ldmicro.cpp void ProgramChanged(void); -*/ + void SetMenusEnabled(BOOL canNegate, BOOL canNormal, BOOL canResetOnly, BOOL canSetOnly, BOOL canDelete, BOOL canInsertEnd, BOOL canInsertOther, BOOL canPushRungDown, BOOL canPushRungUp, BOOL canInsertComment); -/* + void SetUndoEnabled(BOOL undoEnabled, BOOL redoEnabled); void RefreshScrollbars(void); -extern HINSTANCE Instance;*/ +extern HINSTANCE Instance; extern HWID MainWindow; extern HDC Hdc; extern PlcProgram Prog; extern char CurrentSaveFile[MAX_PATH]; -// extern char CurrentCompileFile[MAX_PATH]; +extern char CurrentCompileFile[MAX_PATH]; extern McuIoInfo SupportedMcus[NUM_SUPPORTED_MCUS]; -/* + // memory debugging, because I often get careless; ok() will check that the // heap used for all the program storage is not yet corrupt, and oops() if // it is @@ -557,14 +556,14 @@ extern BOOL SelectionActive; extern BOOL ThisHighlighted; // draw_outputdev.cpp -extern void (*DrawChars)(int, int, char *); -void CALLBACK BlinkCursor(HWND hwnd, UINT msg, UINT_PTR id, DWORD time); -void PaintWindow(void); -void ExportDrawingAsText(char *file); -void InitForDrawing(void); -void SetUpScrollbars(BOOL *horizShown, SCROLLINFO *horiz, SCROLLINFO *vert); -int ScreenRowsAvailable(void); -int ScreenColsAvailable(void); +// extern void (*DrawChars)(int, int, char *); +// void CALLBACK BlinkCursor(HWND hwnd, UINT msg, UINT_PTR id, DWORD time); +// void PaintWindow(void); +// void ExportDrawingAsText(char *file); +// void InitForDrawing(void); +// void SetUpScrollbars(BOOL *horizShown, SCROLLINFO *horiz, SCROLLINFO *vert); +// int ScreenRowsAvailable(void); +// int ScreenColsAvailable(void); extern HFONT FixedWidthFont; extern HFONT FixedWidthFontBold; extern int SelectedGxAfterNextPaint; @@ -667,16 +666,6 @@ void ShowContactsDialog(BOOL *negated, char *name); // coildialog.cpp void ShowCoilDialog(BOOL *negated, BOOL *setOnly, BOOL *resetOnly, char *name); -//advanceddialog.cpp -void ShowAdvancedDialog(void); -void MakeAdvancedDialogClass(void); -void MakeAdvancedWorkspaceClass(void); -void TranslateState(char *name, BOOL state); -void MCUPinState(char *name, BOOL state); -void StartAdvSimulation(void); -void StopAdvSimulation(void); -extern BOOL AdvancedWindowOpen; - //naminglist.cpp void MakeSmplDialogClass(void); @@ -706,6 +695,7 @@ void ShowHelpDialog(BOOL about); Error("Internal error at line %d file '%s'\n", __LINE__, __FILE__); \ exit(1); \ } + void dbp(char *str, ...); void Error(char *str, ...); void *CheckMalloc(size_t n); @@ -749,9 +739,9 @@ void SimulationResetContact(char* name); void SetAdcShadow(char *name, SWORD val); SWORD GetAdcShadow(char *name); void DestroyUartSimulationWindow(void); -void ShowUartSimulationWindow(void);*/ +void ShowUartSimulationWindow(void); extern BOOL InSimulationMode; -/*extern BOOL SimulateRedrawAfterNextCycle; +extern BOOL SimulateRedrawAfterNextCycle; // compilecommon.cpp void AllocStart(void); @@ -780,5 +770,5 @@ void CompileAnsiC(char *outFile); void CompileInterpreted(char *outFile); //Arduino.cpp void CompileArduino(char *outFile); -*/ + #endif diff --git a/ldmicro/includes/simulate.h b/ldmicro/includes/simulate.h deleted file mode 100644 index 7b26ba3..0000000 --- a/ldmicro/includes/simulate.h +++ /dev/null @@ -1,8 +0,0 @@ -/*This file is created with an intention to share simulation functions -with advanced simulation dialog window*/ -#ifndef _SIMULATE_H -#define _SIMULATE_H - -static void SetSingleBit(char *name, BOOL state); -static BOOL SingleBitOn(char *name); -#endif diff --git a/ldmicro/intcode.cpp b/ldmicro/intcode.cpp index 6f1cf15..a577759 100644 --- a/ldmicro/intcode.cpp +++ b/ldmicro/intcode.cpp @@ -22,7 +22,7 @@ // AVR or PIC16 code. // Jonathan Westhues, Nov 2004 //----------------------------------------------------------------------------- -#include <windows.h> +#include "linuxUI.h" #include <stdio.h> #include <setjmp.h> #include <stdlib.h> diff --git a/ldmicro/interpreted.cpp b/ldmicro/interpreted.cpp index 721086a..2295f90 100644 --- a/ldmicro/interpreted.cpp +++ b/ldmicro/interpreted.cpp @@ -22,7 +22,7 @@ // for interpretation. // Jonathan Westhues, Aug 2005 //----------------------------------------------------------------------------- -#include <windows.h> +#include "linuxUI.h" #include <stdio.h> #include <setjmp.h> #include <stdlib.h> diff --git a/ldmicro/iolist.cpp b/ldmicro/iolist.cpp index 15b89c8..e2fc032 100644 --- a/ldmicro/iolist.cpp +++ b/ldmicro/iolist.cpp @@ -25,8 +25,8 @@ // will not be forgotten. Also the dialog box for assigning I/O pins. // Jonathan Westhues, Oct 2004 //----------------------------------------------------------------------------- -#include <windows.h> -#include <commctrl.h> +#include "linuxUI.h" +//#include <commctrl.h> #include <stdio.h> #include <stdlib.h> @@ -42,21 +42,21 @@ static struct { } IoSeenPreviously[MAX_IO_SEEN_PREVIOUSLY]; static int IoSeenPreviouslyCount; -// stuff for the dialog box that lets you choose pin assignments -static BOOL DialogDone; -static BOOL DialogCancel; +// // stuff for the dialog box that lets you choose pin assignments +// static BOOL DialogDone; +// static BOOL DialogCancel; -static HWND IoDialog; +// static HWND IoDialog; -static HWND PinList; -static HWND OkButton; -static HWND CancelButton; +// static HWND PinList; +// static HWND OkButton; +// static HWND CancelButton; -// stuff for the popup that lets you set the simulated value of an analog in -static HWND AnalogSliderMain; -static HWND AnalogSliderTrackbar; -static BOOL AnalogSliderDone; -static BOOL AnalogSliderCancel; +// // stuff for the popup that lets you set the simulated value of an analog in +// static HWND AnalogSliderMain; +// static HWND AnalogSliderTrackbar; +// static BOOL AnalogSliderDone; +// static BOOL AnalogSliderCancel; //----------------------------------------------------------------------------- @@ -394,372 +394,372 @@ void SaveIoListToFile(FILE *f) // Dialog proc for the popup that lets you set the value of an analog input for // simulation. //----------------------------------------------------------------------------- -static LRESULT CALLBACK AnalogSliderDialogProc(HWND hwnd, UINT msg, - WPARAM wParam, LPARAM lParam) -{ - switch (msg) { - case WM_CLOSE: - case WM_DESTROY: - AnalogSliderDone = TRUE; - AnalogSliderCancel = TRUE; - return 1; - - default: - return DefWindowProc(hwnd, msg, wParam, lParam); - } -} +// static LRESULT CALLBACK AnalogSliderDialogProc(HWND hwnd, UINT msg, +// WPARAM wParam, LPARAM lParam) +// { +// switch (msg) { +// case WM_CLOSE: +// case WM_DESTROY: +// AnalogSliderDone = TRUE; +// AnalogSliderCancel = TRUE; +// return 1; + +// default: +// return DefWindowProc(hwnd, msg, wParam, lParam); +// } +// } //----------------------------------------------------------------------------- // A little toolbar-style window that pops up to allow the user to set the // simulated value of an ADC pin. //----------------------------------------------------------------------------- -void ShowAnalogSliderPopup(char *name) -{ - WNDCLASSEX wc; - memset(&wc, 0, sizeof(wc)); - wc.cbSize = sizeof(wc); - - wc.style = CS_BYTEALIGNCLIENT | CS_BYTEALIGNWINDOW | CS_OWNDC | - CS_DBLCLKS; - wc.lpfnWndProc = (WNDPROC)AnalogSliderDialogProc; - wc.hInstance = Instance; - wc.hbrBackground = (HBRUSH)COLOR_BTNSHADOW; - wc.lpszClassName = "LDmicroAnalogSlider"; - wc.lpszMenuName = NULL; - wc.hCursor = LoadCursor(NULL, IDC_ARROW); - - RegisterClassEx(&wc); - - POINT pt; - GetCursorPos(&pt); - - SWORD currentVal = GetAdcShadow(name); - - SWORD maxVal; - if(Prog.mcu) { - maxVal = Prog.mcu->adcMax; - } else { - maxVal = 1023; - } - if(maxVal == 0) { - Error(_("No ADC or ADC not supported for selected micro.")); - return; - } - - int left = pt.x - 10; - // try to put the slider directly under the cursor (though later we might - // realize that that would put the popup off the screen) - int top = pt.y - (15 + (73*currentVal)/maxVal); - - RECT r; - SystemParametersInfo(SPI_GETWORKAREA, 0, &r, 0); - - if(top + 110 >= r.bottom) { - top = r.bottom - 110; - } - if(top < 0) top = 0; +// void ShowAnalogSliderPopup(char *name) +// { +// WNDCLASSEX wc; +// memset(&wc, 0, sizeof(wc)); +// wc.cbSize = sizeof(wc); + +// wc.style = CS_BYTEALIGNCLIENT | CS_BYTEALIGNWINDOW | CS_OWNDC | +// CS_DBLCLKS; +// wc.lpfnWndProc = (WNDPROC)AnalogSliderDialogProc; +// wc.hInstance = Instance; +// wc.hbrBackground = (HBRUSH)COLOR_BTNSHADOW; +// wc.lpszClassName = "LDmicroAnalogSlider"; +// wc.lpszMenuName = NULL; +// wc.hCursor = LoadCursor(NULL, IDC_ARROW); + +// RegisterClassEx(&wc); + +// POINT pt; +// GetCursorPos(&pt); + +// SWORD currentVal = GetAdcShadow(name); + +// SWORD maxVal; +// if(Prog.mcu) { +// maxVal = Prog.mcu->adcMax; +// } else { +// maxVal = 1023; +// } +// if(maxVal == 0) { +// Error(_("No ADC or ADC not supported for selected micro.")); +// return; +// } + +// int left = pt.x - 10; +// // try to put the slider directly under the cursor (though later we might +// // realize that that would put the popup off the screen) +// int top = pt.y - (15 + (73*currentVal)/maxVal); + +// RECT r; +// SystemParametersInfo(SPI_GETWORKAREA, 0, &r, 0); + +// if(top + 110 >= r.bottom) { +// top = r.bottom - 110; +// } +// if(top < 0) top = 0; - AnalogSliderMain = CreateWindowClient(0, "LDmicroAnalogSlider", "I/O Pin", - WS_VISIBLE | WS_POPUP | WS_DLGFRAME, - left, top, 30, 100, NULL, NULL, Instance, NULL); - - AnalogSliderTrackbar = CreateWindowEx(0, TRACKBAR_CLASS, "", WS_CHILD | - TBS_AUTOTICKS | TBS_VERT | TBS_TOOLTIPS | WS_CLIPSIBLINGS | WS_VISIBLE, - 0, 0, 30, 100, AnalogSliderMain, NULL, Instance, NULL); - SendMessage(AnalogSliderTrackbar, TBM_SETRANGE, FALSE, - MAKELONG(0, maxVal)); - SendMessage(AnalogSliderTrackbar, TBM_SETTICFREQ, (maxVal + 1)/8, 0); - SendMessage(AnalogSliderTrackbar, TBM_SETPOS, TRUE, currentVal); - - EnableWindow(MainWindow, FALSE); - ShowWindow(AnalogSliderMain, TRUE); - SetFocus(AnalogSliderTrackbar); - - DWORD ret; - MSG msg; - AnalogSliderDone = FALSE; - AnalogSliderCancel = FALSE; - - SWORD orig = GetAdcShadow(name); - - while(!AnalogSliderDone && (ret = GetMessage(&msg, NULL, 0, 0))) { - SWORD v = (SWORD)SendMessage(AnalogSliderTrackbar, TBM_GETPOS, 0, 0); - - if(msg.message == WM_KEYDOWN) { - if(msg.wParam == VK_RETURN) { - AnalogSliderDone = TRUE; - break; - } else if(msg.wParam == VK_ESCAPE) { - AnalogSliderDone = TRUE; - AnalogSliderCancel = TRUE; - break; - } - } else if(msg.message == WM_LBUTTONUP) { - if(v != orig) { - AnalogSliderDone = TRUE; - } - } - SetAdcShadow(name, v); - - TranslateMessage(&msg); - DispatchMessage(&msg); - } - - if(!AnalogSliderCancel) { - SWORD v = (SWORD)SendMessage(AnalogSliderTrackbar, TBM_GETPOS, 0, 0); - SetAdcShadow(name, v); - } - - EnableWindow(MainWindow, TRUE); - DestroyWindow(AnalogSliderMain); - ListView_RedrawItems(IoList, 0, Prog.io.count - 1); -} +// AnalogSliderMain = CreateWindowClient(0, "LDmicroAnalogSlider", "I/O Pin", +// WS_VISIBLE | WS_POPUP | WS_DLGFRAME, +// left, top, 30, 100, NULL, NULL, Instance, NULL); + +// AnalogSliderTrackbar = CreateWindowEx(0, TRACKBAR_CLASS, "", WS_CHILD | +// TBS_AUTOTICKS | TBS_VERT | TBS_TOOLTIPS | WS_CLIPSIBLINGS | WS_VISIBLE, +// 0, 0, 30, 100, AnalogSliderMain, NULL, Instance, NULL); +// SendMessage(AnalogSliderTrackbar, TBM_SETRANGE, FALSE, +// MAKELONG(0, maxVal)); +// SendMessage(AnalogSliderTrackbar, TBM_SETTICFREQ, (maxVal + 1)/8, 0); +// SendMessage(AnalogSliderTrackbar, TBM_SETPOS, TRUE, currentVal); + +// EnableWindow(MainWindow, FALSE); +// ShowWindow(AnalogSliderMain, TRUE); +// SetFocus(AnalogSliderTrackbar); + +// DWORD ret; +// MSG msg; +// AnalogSliderDone = FALSE; +// AnalogSliderCancel = FALSE; + +// SWORD orig = GetAdcShadow(name); + +// while(!AnalogSliderDone && (ret = GetMessage(&msg, NULL, 0, 0))) { +// SWORD v = (SWORD)SendMessage(AnalogSliderTrackbar, TBM_GETPOS, 0, 0); + +// if(msg.message == WM_KEYDOWN) { +// if(msg.wParam == VK_RETURN) { +// AnalogSliderDone = TRUE; +// break; +// } else if(msg.wParam == VK_ESCAPE) { +// AnalogSliderDone = TRUE; +// AnalogSliderCancel = TRUE; +// break; +// } +// } else if(msg.message == WM_LBUTTONUP) { +// if(v != orig) { +// AnalogSliderDone = TRUE; +// } +// } +// SetAdcShadow(name, v); + +// TranslateMessage(&msg); +// DispatchMessage(&msg); +// } + +// if(!AnalogSliderCancel) { +// SWORD v = (SWORD)SendMessage(AnalogSliderTrackbar, TBM_GETPOS, 0, 0); +// SetAdcShadow(name, v); +// } + +// EnableWindow(MainWindow, TRUE); +// DestroyWindow(AnalogSliderMain); +// ListView_RedrawItems(IoList, 0, Prog.io.count - 1); +// } //----------------------------------------------------------------------------- // Window proc for the contacts dialog box //----------------------------------------------------------------------------- -static LRESULT CALLBACK IoDialogProc(HWND hwnd, UINT msg, WPARAM wParam, - LPARAM lParam) -{ - switch (msg) { - case WM_COMMAND: { - HWND h = (HWND)lParam; - if(h == OkButton && wParam == BN_CLICKED) { - DialogDone = TRUE; - } else if(h == CancelButton && wParam == BN_CLICKED) { - DialogDone = TRUE; - DialogCancel = TRUE; - } else if(h == PinList && HIWORD(wParam) == LBN_DBLCLK) { - DialogDone = TRUE; - } - break; - } - - case WM_CLOSE: - case WM_DESTROY: - DialogDone = TRUE; - DialogCancel = TRUE; - return 1; - - default: - return DefWindowProc(hwnd, msg, wParam, lParam); - } - - return 1; -} +// static LRESULT CALLBACK IoDialogProc(HWND hwnd, UINT msg, WPARAM wParam, +// LPARAM lParam) +// { +// switch (msg) { +// case WM_COMMAND: { +// HWND h = (HWND)lParam; +// if(h == OkButton && wParam == BN_CLICKED) { +// DialogDone = TRUE; +// } else if(h == CancelButton && wParam == BN_CLICKED) { +// DialogDone = TRUE; +// DialogCancel = TRUE; +// } else if(h == PinList && HIWORD(wParam) == LBN_DBLCLK) { +// DialogDone = TRUE; +// } +// break; +// } + +// case WM_CLOSE: +// case WM_DESTROY: +// DialogDone = TRUE; +// DialogCancel = TRUE; +// return 1; + +// default: +// return DefWindowProc(hwnd, msg, wParam, lParam); +// } + +// return 1; +// } //----------------------------------------------------------------------------- // Create our window class; nothing exciting. //----------------------------------------------------------------------------- -static BOOL MakeWindowClass() -{ - WNDCLASSEX wc; - memset(&wc, 0, sizeof(wc)); - wc.cbSize = sizeof(wc); - - wc.style = CS_BYTEALIGNCLIENT | CS_BYTEALIGNWINDOW | CS_OWNDC | - CS_DBLCLKS; - wc.lpfnWndProc = (WNDPROC)IoDialogProc; - wc.hInstance = Instance; - wc.hbrBackground = (HBRUSH)COLOR_BTNSHADOW; - wc.lpszClassName = "LDmicroIo"; - wc.lpszMenuName = NULL; - wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.hIcon = (HICON)LoadImage(Instance, MAKEINTRESOURCE(4000), - IMAGE_ICON, 32, 32, 0); - wc.hIconSm = (HICON)LoadImage(Instance, MAKEINTRESOURCE(4000), - IMAGE_ICON, 16, 16, 0); - - return RegisterClassEx(&wc); -} - -static void MakeControls(void) -{ - HWND textLabel = CreateWindowEx(0, WC_STATIC, _("Assign:"), - WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE, - 6, 1, 80, 17, IoDialog, NULL, Instance, NULL); - NiceFont(textLabel); - - PinList = CreateWindowEx(WS_EX_CLIENTEDGE, WC_LISTBOX, "", - WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE | WS_VSCROLL | - LBS_NOTIFY, 6, 18, 95, 320, IoDialog, NULL, Instance, NULL); - FixedFont(PinList); - - OkButton = CreateWindowEx(0, WC_BUTTON, _("OK"), - WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE | BS_DEFPUSHBUTTON, - 6, 325, 95, 23, IoDialog, NULL, Instance, NULL); - NiceFont(OkButton); - - CancelButton = CreateWindowEx(0, WC_BUTTON, _("Cancel"), - WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE, - 6, 356, 95, 23, IoDialog, NULL, Instance, NULL); - NiceFont(CancelButton); -} - -void ShowIoDialog(int item) -{ - if(!Prog.mcu) { - MessageBox(MainWindow, - _("No microcontroller has been selected. You must select a " - "microcontroller before you can assign I/O pins.\r\n\r\n" - "Select a microcontroller under the Settings menu and try " - "again."), _("I/O Pin Assignment"), MB_OK | MB_ICONWARNING); - return; - } - - if(Prog.mcu->whichIsa == ISA_ANSIC) { - Error(_("Can't specify I/O assignment for ANSI C target; compile and " - "see comments in generated source code.")); - return; - } - - if(Prog.mcu->whichIsa == ISA_INTERPRETED) { - Error(_("Can't specify I/O assignment for interpretable target; see " - "comments in reference implementation of interpreter.")); - return; - } - - if(Prog.io.assignment[item].name[0] != 'X' && - Prog.io.assignment[item].name[0] != 'Y' && - Prog.io.assignment[item].name[0] != 'A') - { - Error(_("Can only assign pin number to input/output pins (Xname or " - "Yname or Aname).")); - return; - } - - if(Prog.io.assignment[item].name[0] == 'A' && Prog.mcu->adcCount == 0) { - Error(_("No ADC or ADC not supported for this micro.")); - return; - } - - if(strcmp(Prog.io.assignment[item].name+1, "new")==0) { - Error(_("Rename I/O from default name ('%s') before assigning " - "MCU pin."), Prog.io.assignment[item].name); - return; - } - - MakeWindowClass(); - - // We need the TOOLWINDOW style, or else the window will be forced to - // a minimum width greater than our current width. And without the - // APPWINDOW style, it becomes impossible to get the window back (by - // Alt+Tab or taskbar). - IoDialog = CreateWindowClient(WS_EX_TOOLWINDOW | WS_EX_APPWINDOW, - "LDmicroIo", _("I/O Pin"), - WS_OVERLAPPED | WS_SYSMENU, - 100, 100, 107, 387, NULL, NULL, Instance, NULL); - - MakeControls(); - - SendMessage(PinList, LB_ADDSTRING, 0, (LPARAM)_("(no pin)")); - int i; - for(i = 0; i < Prog.mcu->pinCount; i++) { - int j; - for(j = 0; j < Prog.io.count; j++) { - if(j == item) continue; - if(Prog.io.assignment[j].pin == Prog.mcu->pinInfo[i].pin) { - goto cant_use_this_io; - } - } - - if(UartFunctionUsed() && Prog.mcu && - ((Prog.mcu->pinInfo[i].pin == Prog.mcu->uartNeeds.rxPin) || - (Prog.mcu->pinInfo[i].pin == Prog.mcu->uartNeeds.txPin))) - { - goto cant_use_this_io; - } - - if(PwmFunctionUsed() && - Prog.mcu->pinInfo[i].pin == Prog.mcu->pwmNeedsPin) - { - goto cant_use_this_io; - } - - if(Prog.io.assignment[item].name[0] == 'A') { - for(j = 0; j < Prog.mcu->adcCount; j++) { - if(Prog.mcu->adcInfo[j].pin == Prog.mcu->pinInfo[i].pin) { - // okay; we know how to connect it up to the ADC - break; - } - } - if(j == Prog.mcu->adcCount) { - goto cant_use_this_io; - } - } - - char buf[40]; - if(Prog.mcu->pinCount <= 21) { - sprintf(buf, "%3d %c%c%d", Prog.mcu->pinInfo[i].pin, - Prog.mcu->portPrefix, Prog.mcu->pinInfo[i].port, - Prog.mcu->pinInfo[i].bit); - } else { - sprintf(buf, "%3d %c%c%d", Prog.mcu->pinInfo[i].pin, - Prog.mcu->portPrefix, Prog.mcu->pinInfo[i].port, - Prog.mcu->pinInfo[i].bit); - } - SendMessage(PinList, LB_ADDSTRING, 0, (LPARAM)buf); -cant_use_this_io:; - } - - EnableWindow(MainWindow, FALSE); - ShowWindow(IoDialog, TRUE); - SetFocus(PinList); - - MSG msg; - DWORD ret; - DialogDone = FALSE; - DialogCancel = FALSE; - while((ret = GetMessage(&msg, NULL, 0, 0)) && !DialogDone) { - if(msg.message == WM_KEYDOWN) { - if(msg.wParam == VK_RETURN) { - DialogDone = TRUE; - break; - } else if(msg.wParam == VK_ESCAPE) { - DialogDone = TRUE; - DialogCancel = TRUE; - break; - } - } - - if(IsDialogMessage(IoDialog, &msg)) continue; - TranslateMessage(&msg); - DispatchMessage(&msg); - } - - if(!DialogCancel) { - int sel = SendMessage(PinList, LB_GETCURSEL, 0, 0); - char pin[16]; - SendMessage(PinList, LB_GETTEXT, (WPARAM)sel, (LPARAM)pin); - if(strcmp(pin, _("(no pin)"))==0) { - int i; - for(i = 0; i < IoSeenPreviouslyCount; i++) { - if(strcmp(IoSeenPreviously[i].name, - Prog.io.assignment[item].name)==0) - { - IoSeenPreviously[i].pin = NO_PIN_ASSIGNED; - } - } - Prog.io.assignment[item].pin = NO_PIN_ASSIGNED; - } else { - Prog.io.assignment[item].pin = atoi(pin); - // Only one name can be bound to each pin; make sure that there's - // not another entry for this pin in the IoSeenPreviously list, - // that might get used if the user creates a new pin with that - // name. - int i; - for(i = 0; i < IoSeenPreviouslyCount; i++) { - if(IoSeenPreviously[i].pin == atoi(pin)) { - IoSeenPreviously[i].pin = NO_PIN_ASSIGNED; - } - } - } - } - - EnableWindow(MainWindow, TRUE); - DestroyWindow(IoDialog); - return; -} +// static BOOL MakeWindowClass() +// { +// WNDCLASSEX wc; +// memset(&wc, 0, sizeof(wc)); +// wc.cbSize = sizeof(wc); + +// wc.style = CS_BYTEALIGNCLIENT | CS_BYTEALIGNWINDOW | CS_OWNDC | +// CS_DBLCLKS; +// wc.lpfnWndProc = (WNDPROC)IoDialogProc; +// wc.hInstance = Instance; +// wc.hbrBackground = (HBRUSH)COLOR_BTNSHADOW; +// wc.lpszClassName = "LDmicroIo"; +// wc.lpszMenuName = NULL; +// wc.hCursor = LoadCursor(NULL, IDC_ARROW); +// wc.hIcon = (HICON)LoadImage(Instance, MAKEINTRESOURCE(4000), +// IMAGE_ICON, 32, 32, 0); +// wc.hIconSm = (HICON)LoadImage(Instance, MAKEINTRESOURCE(4000), +// IMAGE_ICON, 16, 16, 0); + +// return RegisterClassEx(&wc); +// } + +// static void MakeControls(void) +// { +// HWND textLabel = CreateWindowEx(0, WC_STATIC, _("Assign:"), +// WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE, +// 6, 1, 80, 17, IoDialog, NULL, Instance, NULL); +// NiceFont(textLabel); + +// PinList = CreateWindowEx(WS_EX_CLIENTEDGE, WC_LISTBOX, "", +// WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE | WS_VSCROLL | +// LBS_NOTIFY, 6, 18, 95, 320, IoDialog, NULL, Instance, NULL); +// FixedFont(PinList); + +// OkButton = CreateWindowEx(0, WC_BUTTON, _("OK"), +// WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE | BS_DEFPUSHBUTTON, +// 6, 325, 95, 23, IoDialog, NULL, Instance, NULL); +// NiceFont(OkButton); + +// CancelButton = CreateWindowEx(0, WC_BUTTON, _("Cancel"), +// WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE, +// 6, 356, 95, 23, IoDialog, NULL, Instance, NULL); +// NiceFont(CancelButton); +// } + +// void ShowIoDialog(int item) +// { +// if(!Prog.mcu) { +// MessageBox(MainWindow, +// _("No microcontroller has been selected. You must select a " +// "microcontroller before you can assign I/O pins.\r\n\r\n" +// "Select a microcontroller under the Settings menu and try " +// "again."), _("I/O Pin Assignment"), MB_OK | MB_ICONWARNING); +// return; +// } + +// if(Prog.mcu->whichIsa == ISA_ANSIC) { +// Error(_("Can't specify I/O assignment for ANSI C target; compile and " +// "see comments in generated source code.")); +// return; +// } + +// if(Prog.mcu->whichIsa == ISA_INTERPRETED) { +// Error(_("Can't specify I/O assignment for interpretable target; see " +// "comments in reference implementation of interpreter.")); +// return; +// } + +// if(Prog.io.assignment[item].name[0] != 'X' && +// Prog.io.assignment[item].name[0] != 'Y' && +// Prog.io.assignment[item].name[0] != 'A') +// { +// Error(_("Can only assign pin number to input/output pins (Xname or " +// "Yname or Aname).")); +// return; +// } + +// if(Prog.io.assignment[item].name[0] == 'A' && Prog.mcu->adcCount == 0) { +// Error(_("No ADC or ADC not supported for this micro.")); +// return; +// } + +// if(strcmp(Prog.io.assignment[item].name+1, "new")==0) { +// Error(_("Rename I/O from default name ('%s') before assigning " +// "MCU pin."), Prog.io.assignment[item].name); +// return; +// } + +// MakeWindowClass(); + +// // We need the TOOLWINDOW style, or else the window will be forced to +// // a minimum width greater than our current width. And without the +// // APPWINDOW style, it becomes impossible to get the window back (by +// // Alt+Tab or taskbar). +// IoDialog = CreateWindowClient(WS_EX_TOOLWINDOW | WS_EX_APPWINDOW, +// "LDmicroIo", _("I/O Pin"), +// WS_OVERLAPPED | WS_SYSMENU, +// 100, 100, 107, 387, NULL, NULL, Instance, NULL); + +// MakeControls(); + +// SendMessage(PinList, LB_ADDSTRING, 0, (LPARAM)_("(no pin)")); +// int i; +// for(i = 0; i < Prog.mcu->pinCount; i++) { +// int j; +// for(j = 0; j < Prog.io.count; j++) { +// if(j == item) continue; +// if(Prog.io.assignment[j].pin == Prog.mcu->pinInfo[i].pin) { +// goto cant_use_this_io; +// } +// } + +// if(UartFunctionUsed() && Prog.mcu && +// ((Prog.mcu->pinInfo[i].pin == Prog.mcu->uartNeeds.rxPin) || +// (Prog.mcu->pinInfo[i].pin == Prog.mcu->uartNeeds.txPin))) +// { +// goto cant_use_this_io; +// } + +// if(PwmFunctionUsed() && +// Prog.mcu->pinInfo[i].pin == Prog.mcu->pwmNeedsPin) +// { +// goto cant_use_this_io; +// } + +// if(Prog.io.assignment[item].name[0] == 'A') { +// for(j = 0; j < Prog.mcu->adcCount; j++) { +// if(Prog.mcu->adcInfo[j].pin == Prog.mcu->pinInfo[i].pin) { +// // okay; we know how to connect it up to the ADC +// break; +// } +// } +// if(j == Prog.mcu->adcCount) { +// goto cant_use_this_io; +// } +// } + +// char buf[40]; +// if(Prog.mcu->pinCount <= 21) { +// sprintf(buf, "%3d %c%c%d", Prog.mcu->pinInfo[i].pin, +// Prog.mcu->portPrefix, Prog.mcu->pinInfo[i].port, +// Prog.mcu->pinInfo[i].bit); +// } else { +// sprintf(buf, "%3d %c%c%d", Prog.mcu->pinInfo[i].pin, +// Prog.mcu->portPrefix, Prog.mcu->pinInfo[i].port, +// Prog.mcu->pinInfo[i].bit); +// } +// SendMessage(PinList, LB_ADDSTRING, 0, (LPARAM)buf); +// cant_use_this_io:; +// } + +// EnableWindow(MainWindow, FALSE); +// ShowWindow(IoDialog, TRUE); +// SetFocus(PinList); + +// MSG msg; +// DWORD ret; +// DialogDone = FALSE; +// DialogCancel = FALSE; +// while((ret = GetMessage(&msg, NULL, 0, 0)) && !DialogDone) { +// if(msg.message == WM_KEYDOWN) { +// if(msg.wParam == VK_RETURN) { +// DialogDone = TRUE; +// break; +// } else if(msg.wParam == VK_ESCAPE) { +// DialogDone = TRUE; +// DialogCancel = TRUE; +// break; +// } +// } + +// if(IsDialogMessage(IoDialog, &msg)) continue; +// TranslateMessage(&msg); +// DispatchMessage(&msg); +// } + +// if(!DialogCancel) { +// int sel = SendMessage(PinList, LB_GETCURSEL, 0, 0); +// char pin[16]; +// SendMessage(PinList, LB_GETTEXT, (WPARAM)sel, (LPARAM)pin); +// if(strcmp(pin, _("(no pin)"))==0) { +// int i; +// for(i = 0; i < IoSeenPreviouslyCount; i++) { +// if(strcmp(IoSeenPreviously[i].name, +// Prog.io.assignment[item].name)==0) +// { +// IoSeenPreviously[i].pin = NO_PIN_ASSIGNED; +// } +// } +// Prog.io.assignment[item].pin = NO_PIN_ASSIGNED; +// } else { +// Prog.io.assignment[item].pin = atoi(pin); +// // Only one name can be bound to each pin; make sure that there's +// // not another entry for this pin in the IoSeenPreviously list, +// // that might get used if the user creates a new pin with that +// // name. +// int i; +// for(i = 0; i < IoSeenPreviouslyCount; i++) { +// if(IoSeenPreviously[i].pin == atoi(pin)) { +// IoSeenPreviously[i].pin = NO_PIN_ASSIGNED; +// } +// } +// } +// } + +// EnableWindow(MainWindow, TRUE); +// DestroyWindow(IoDialog); +// return; +// } //----------------------------------------------------------------------------- // Called in response to a notify for the listview. Handles click, text-edit @@ -767,119 +767,119 @@ cant_use_this_io:; // where (LPSTR_TEXTCALLBACK); that way we don't have two parallel copies of // the I/O list to keep in sync. //----------------------------------------------------------------------------- -void IoListProc(NMHDR *h) -{ - switch(h->code) { - case LVN_GETDISPINFO: { - NMLVDISPINFO *i = (NMLVDISPINFO *)h; - int item = i->item.iItem; - switch(i->item.iSubItem) { - case LV_IO_PIN: - // Don't confuse people by displaying bogus pin assignments - // for the C target. - if(Prog.mcu && (Prog.mcu->whichIsa == ISA_ANSIC || - Prog.mcu->whichIsa == ISA_INTERPRETED) ) - { - strcpy(i->item.pszText, ""); - break; - } - - PinNumberForIo(i->item.pszText, - &(Prog.io.assignment[item])); - break; - - case LV_IO_TYPE: { - char *s = IoTypeToString(Prog.io.assignment[item].type); - strcpy(i->item.pszText, s); - break; - } - case LV_IO_NAME: - strcpy(i->item.pszText, Prog.io.assignment[item].name); - break; - - case LV_IO_PORT: { - // Don't confuse people by displaying bogus pin assignments - // for the C target. - if(Prog.mcu && Prog.mcu->whichIsa == ISA_ANSIC) { - strcpy(i->item.pszText, ""); - break; - } - - int type = Prog.io.assignment[item].type; - if(type != IO_TYPE_DIG_INPUT && type != IO_TYPE_DIG_OUTPUT - && type != IO_TYPE_READ_ADC) - { - strcpy(i->item.pszText, ""); - break; - } - - int pin = Prog.io.assignment[item].pin; - if(pin == NO_PIN_ASSIGNED || !Prog.mcu) { - strcpy(i->item.pszText, ""); - break; - } - - if(UartFunctionUsed() && Prog.mcu) { - if((Prog.mcu->uartNeeds.rxPin == pin) || - (Prog.mcu->uartNeeds.txPin == pin)) - { - strcpy(i->item.pszText, _("<UART needs!>")); - break; - } - } - - if(PwmFunctionUsed() && Prog.mcu) { - if(Prog.mcu->pwmNeedsPin == pin) { - strcpy(i->item.pszText, _("<PWM needs!>")); - break; - } - } - - int j; - for(j = 0; j < Prog.mcu->pinCount; j++) { - if(Prog.mcu->pinInfo[j].pin == pin) { - sprintf(i->item.pszText, "%c%c%d", - Prog.mcu->portPrefix, - Prog.mcu->pinInfo[j].port, - Prog.mcu->pinInfo[j].bit); - break; - } - } - if(j == Prog.mcu->pinCount) { - sprintf(i->item.pszText, _("<not an I/O!>")); - } - break; - } - - case LV_IO_STATE: { - if(InSimulationMode) { - char *name = Prog.io.assignment[item].name; - DescribeForIoList(name, i->item.pszText); - } else { - strcpy(i->item.pszText, ""); - } - break; - } - - } - break; - } - case LVN_ITEMACTIVATE: { - NMITEMACTIVATE *i = (NMITEMACTIVATE *)h; - if(InSimulationMode) { - char *name = Prog.io.assignment[i->iItem].name; - if(name[0] == 'X') { - SimulationToggleContact(name); - } else if(name[0] == 'A') { - ShowAnalogSliderPopup(name); - } - } else { - UndoRemember(); - ShowIoDialog(i->iItem); - ProgramChanged(); - InvalidateRect(MainWindow, NULL, FALSE); - } - break; - } - } -} +// void IoListProc(NMHDR *h) +// { +// switch(h->code) { +// case LVN_GETDISPINFO: { +// NMLVDISPINFO *i = (NMLVDISPINFO *)h; +// int item = i->item.iItem; +// switch(i->item.iSubItem) { +// case LV_IO_PIN: +// // Don't confuse people by displaying bogus pin assignments +// // for the C target. +// if(Prog.mcu && (Prog.mcu->whichIsa == ISA_ANSIC || +// Prog.mcu->whichIsa == ISA_INTERPRETED) ) +// { +// strcpy(i->item.pszText, ""); +// break; +// } + +// PinNumberForIo(i->item.pszText, +// &(Prog.io.assignment[item])); +// break; + +// case LV_IO_TYPE: { +// char *s = IoTypeToString(Prog.io.assignment[item].type); +// strcpy(i->item.pszText, s); +// break; +// } +// case LV_IO_NAME: +// strcpy(i->item.pszText, Prog.io.assignment[item].name); +// break; + +// case LV_IO_PORT: { +// // Don't confuse people by displaying bogus pin assignments +// // for the C target. +// if(Prog.mcu && Prog.mcu->whichIsa == ISA_ANSIC) { +// strcpy(i->item.pszText, ""); +// break; +// } + +// int type = Prog.io.assignment[item].type; +// if(type != IO_TYPE_DIG_INPUT && type != IO_TYPE_DIG_OUTPUT +// && type != IO_TYPE_READ_ADC) +// { +// strcpy(i->item.pszText, ""); +// break; +// } + +// int pin = Prog.io.assignment[item].pin; +// if(pin == NO_PIN_ASSIGNED || !Prog.mcu) { +// strcpy(i->item.pszText, ""); +// break; +// } + +// if(UartFunctionUsed() && Prog.mcu) { +// if((Prog.mcu->uartNeeds.rxPin == pin) || +// (Prog.mcu->uartNeeds.txPin == pin)) +// { +// strcpy(i->item.pszText, _("<UART needs!>")); +// break; +// } +// } + +// if(PwmFunctionUsed() && Prog.mcu) { +// if(Prog.mcu->pwmNeedsPin == pin) { +// strcpy(i->item.pszText, _("<PWM needs!>")); +// break; +// } +// } + +// int j; +// for(j = 0; j < Prog.mcu->pinCount; j++) { +// if(Prog.mcu->pinInfo[j].pin == pin) { +// sprintf(i->item.pszText, "%c%c%d", +// Prog.mcu->portPrefix, +// Prog.mcu->pinInfo[j].port, +// Prog.mcu->pinInfo[j].bit); +// break; +// } +// } +// if(j == Prog.mcu->pinCount) { +// sprintf(i->item.pszText, _("<not an I/O!>")); +// } +// break; +// } + +// case LV_IO_STATE: { +// if(InSimulationMode) { +// char *name = Prog.io.assignment[item].name; +// DescribeForIoList(name, i->item.pszText); +// } else { +// strcpy(i->item.pszText, ""); +// } +// break; +// } + +// } +// break; +// } +// case LVN_ITEMACTIVATE: { +// NMITEMACTIVATE *i = (NMITEMACTIVATE *)h; +// if(InSimulationMode) { +// char *name = Prog.io.assignment[i->iItem].name; +// if(name[0] == 'X') { +// SimulationToggleContact(name); +// } else if(name[0] == 'A') { +// ShowAnalogSliderPopup(name); +// } +// } else { +// UndoRemember(); +// ShowIoDialog(i->iItem); +// ProgramChanged(); +// InvalidateRect(MainWindow, NULL, FALSE); +// } +// break; +// } +// } +// } diff --git a/ldmicro/lang.cpp b/ldmicro/lang.cpp index 4be05d0..67952bc 100644 --- a/ldmicro/lang.cpp +++ b/ldmicro/lang.cpp @@ -24,7 +24,7 @@ // table. If it fails then it just returns the English. // Jonathan Westhues, Apr 2007 //----------------------------------------------------------------------------- -#include <windows.h> +#include "linuxUI.h" #include <stdio.h> #include <stdlib.h> @@ -42,7 +42,8 @@ typedef struct LangTag { // These are the actual translation tables, so should be included in just // one place. -#include "obj/lang-tables.h" +//#include "obj/lang-tables.h" +#define LDLANG_EN char *_(char *in) { diff --git a/ldmicro/ldinterpret.c b/ldmicro/ldinterpret.c index ce20dbc..6f18d44 100644 --- a/ldmicro/ldinterpret.c +++ b/ldmicro/ldinterpret.c @@ -36,7 +36,7 @@ //----------------------------------------------------------------------------- #include <stdio.h> #include <ctype.h> -#include <windows.h> +#include "linuxUI.h" #define INTCODE_H_CONSTANTS_ONLY #include "intcode.h" diff --git a/ldmicro/ldmicro.cpp b/ldmicro/ldmicro.cpp index 8785753..e803bba 100644 --- a/ldmicro/ldmicro.cpp +++ b/ldmicro/ldmicro.cpp @@ -28,11 +28,9 @@ #include <stdio.h> #include <stdlib.h> - #include "ldmicro.h" #include "freezeLD.h" #include "mcutable.h" -#include "advanceddialog.h" HINSTANCE Instance; @@ -41,7 +39,7 @@ HDC Hdc; // parameters used to capture the mouse when implementing our totally non- // general splitter control -static HHOOK MouseHookHandle; +//static HHOOK MouseHookHandle; static int MouseY; // For the open/save dialog boxes @@ -67,75 +65,75 @@ PlcProgram Prog; // Get a filename with a common dialog box and then save the program to that // file and then set our default filename to that. //----------------------------------------------------------------------------- -static BOOL SaveAsDialog(void) -{ - OPENFILENAME ofn; - - memset(&ofn, 0, sizeof(ofn)); - ofn.lStructSize = sizeof(ofn); - ofn.hInstance = Instance; - ofn.lpstrFilter = LDMICRO_PATTERN; - ofn.lpstrDefExt = "ld"; - ofn.lpstrFile = CurrentSaveFile; - ofn.nMaxFile = sizeof(CurrentSaveFile); - ofn.Flags = OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; - - if(!GetSaveFileName(&ofn)) - return FALSE; - - if(!SaveProjectToFile(CurrentSaveFile)) { - Error(_("Couldn't write to '%s'."), CurrentSaveFile); - return FALSE; - } else { - ProgramChangedNotSaved = FALSE; - return TRUE; - } -} +// static BOOL SaveAsDialog(void) +// { +// OPENFILENAME ofn; + +// memset(&ofn, 0, sizeof(ofn)); +// ofn.lStructSize = sizeof(ofn); +// ofn.hInstance = Instance; +// ofn.lpstrFilter = LDMICRO_PATTERN; +// ofn.lpstrDefExt = "ld"; +// ofn.lpstrFile = CurrentSaveFile; +// ofn.nMaxFile = sizeof(CurrentSaveFile); +// ofn.Flags = OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; + +// if(!GetSaveFileName(&ofn)) +// return FALSE; + +// if(!SaveProjectToFile(CurrentSaveFile)) { +// Error(_("Couldn't write to '%s'."), CurrentSaveFile); +// return FALSE; +// } else { +// ProgramChangedNotSaved = FALSE; +// return TRUE; +// } +// } //----------------------------------------------------------------------------- // Get a filename with a common dialog box and then export the program as // an ASCII art drawing. //----------------------------------------------------------------------------- -static void ExportDialog(void) -{ - char exportFile[MAX_PATH]; - OPENFILENAME ofn; +// static void ExportDialog(void) +// { +// char exportFile[MAX_PATH]; +// OPENFILENAME ofn; - exportFile[0] = '\0'; +// exportFile[0] = '\0'; - memset(&ofn, 0, sizeof(ofn)); - ofn.lStructSize = sizeof(ofn); - ofn.hInstance = Instance; - ofn.lpstrFilter = TXT_PATTERN; - ofn.lpstrFile = exportFile; - ofn.lpstrTitle = _("Export As Text"); - ofn.nMaxFile = sizeof(exportFile); - ofn.Flags = OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; +// memset(&ofn, 0, sizeof(ofn)); +// ofn.lStructSize = sizeof(ofn); +// ofn.hInstance = Instance; +// ofn.lpstrFilter = TXT_PATTERN; +// ofn.lpstrFile = exportFile; +// ofn.lpstrTitle = _("Export As Text"); +// ofn.nMaxFile = sizeof(exportFile); +// ofn.Flags = OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT; - if(!GetSaveFileName(&ofn)) - return; +// if(!GetSaveFileName(&ofn)) +// return; - ExportDrawingAsText(exportFile); -} +// ExportDrawingAsText(exportFile); +// } //----------------------------------------------------------------------------- // If we already have a filename, save the program to that. Otherwise same // as Save As. Returns TRUE if it worked, else returns FALSE. //----------------------------------------------------------------------------- -static BOOL SaveProgram(void) -{ - if(strlen(CurrentSaveFile)) { - if(!SaveProjectToFile(CurrentSaveFile)) { - Error(_("Couldn't write to '%s'."), CurrentSaveFile); - return FALSE; - } else { - ProgramChangedNotSaved = FALSE; - return TRUE; - } - } else { - return SaveAsDialog(); - } -} +// static BOOL SaveProgram(void) +// { +// if(strlen(CurrentSaveFile)) { +// if(!SaveProjectToFile(CurrentSaveFile)) { +// Error(_("Couldn't write to '%s'."), CurrentSaveFile); +// return FALSE; +// } else { +// ProgramChangedNotSaved = FALSE; +// return TRUE; +// } +// } else { +// return SaveAsDialog(); +// } +// } //----------------------------------------------------------------------------- // Compile the program to a hex file for the target micro. Get the output @@ -205,92 +203,87 @@ static void CompileProgram(BOOL compileAs) // or to cancel the operation they are performing. Return TRUE if they want // to cancel. //----------------------------------------------------------------------------- -BOOL CheckSaveUserCancels(void) -{ - if(!ProgramChangedNotSaved) { - // no problem - return FALSE; - } - - int r = MessageBox(MainWindow, - _("The program has changed since it was last saved.\r\n\r\n" - "Do you want to save the changes?"), "LDmicro", - MB_YESNOCANCEL | MB_ICONWARNING); - switch(r) { - case IDYES: - if(SaveProgram()) - return FALSE; - else - return TRUE; - - case IDNO: - return FALSE; - - case IDCANCEL: - return TRUE; - - default: - oops(); - } -} +// BOOL CheckSaveUserCancels(void) +// { +// if(!ProgramChangedNotSaved) { +// // no problem +// return FALSE; +// } + +// int r = MessageBox(MainWindow, +// _("The program has changed since it was last saved.\r\n\r\n" +// "Do you want to save the changes?"), "LDmicro", +// MB_YESNOCANCEL | MB_ICONWARNING); +// switch(r) { +// case IDYES: +// if(SaveProgram()) +// return FALSE; +// else +// return TRUE; + +// case IDNO: +// return FALSE; + +// case IDCANCEL: +// return TRUE; + +// default: +// oops(); +// } +// } //----------------------------------------------------------------------------- // Load a new program from a file. If it succeeds then set our default filename // to that, else we end up with an empty file then. //----------------------------------------------------------------------------- -static void OpenDialog(void) -{ - OPENFILENAME ofn; - - char tempSaveFile[MAX_PATH] = ""; - - memset(&ofn, 0, sizeof(ofn)); - ofn.lStructSize = sizeof(ofn); - ofn.hInstance = Instance; - ofn.lpstrFilter = LDMICRO_PATTERN; - ofn.lpstrDefExt = "ld"; - ofn.lpstrFile = tempSaveFile; - ofn.nMaxFile = sizeof(tempSaveFile); - ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; - - if(!GetOpenFileName(&ofn)) - return; - - if(!LoadProjectFromFile(tempSaveFile)) { - Error(_("Couldn't open '%s'."), tempSaveFile); - CurrentSaveFile[0] = '\0'; - } else { - ProgramChangedNotSaved = FALSE; - strcpy(CurrentSaveFile, tempSaveFile); - UndoFlush(); - } - - GenerateIoListDontLoseSelection(); - RefreshScrollbars(); - UpdateMainWindowTitleBar(); -} +// static void OpenDialog(void) +// { +// OPENFILENAME ofn; + +// char tempSaveFile[MAX_PATH] = ""; + +// memset(&ofn, 0, sizeof(ofn)); +// ofn.lStructSize = sizeof(ofn); +// ofn.hInstance = Instance; +// ofn.lpstrFilter = LDMICRO_PATTERN; +// ofn.lpstrDefExt = "ld"; +// ofn.lpstrFile = tempSaveFile; +// ofn.nMaxFile = sizeof(tempSaveFile); +// ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; + +// if(!GetOpenFileName(&ofn)) +// return; + +// if(!LoadProjectFromFile(tempSaveFile)) { +// Error(_("Couldn't open '%s'."), tempSaveFile); +// CurrentSaveFile[0] = '\0'; +// } else { +// ProgramChangedNotSaved = FALSE; +// strcpy(CurrentSaveFile, tempSaveFile); +// UndoFlush(); +// } + +// GenerateIoListDontLoseSelection(); +// RefreshScrollbars(); +// UpdateMainWindowTitleBar(); +// } //----------------------------------------------------------------------------- // Housekeeping required when the program changes: mark the program as // changed so that we ask if user wants to save before exiting, and update // the I/O list. //----------------------------------------------------------------------------- -void ProgramChanged(void) -{ - ProgramChangedNotSaved = TRUE; - GenerateIoListDontLoseSelection(); - RefreshScrollbars(); - if(AdvancedWindowOpen) - { - FlushPinNames(); - PopulateNamingList(); - } -} -#define CHANGING_PROGRAM(x) { \ - UndoRemember(); \ - x; \ - ProgramChanged(); \ - } +// void ProgramChanged(void) +// { +// ProgramChangedNotSaved = TRUE; +// GenerateIoListDontLoseSelection(); +// RefreshScrollbars(); +// } +// #define CHANGING_PROGRAM(x) { \ +// UndoRemember(); \ +// x; \ +// ProgramChanged(); \ +// } //----------------------------------------------------------------------------- // Hook that we install when the user starts dragging the `splitter,' in case @@ -298,786 +291,801 @@ void ProgramChanged(void) // the listview in response to mouse move, and unhook ourselves when they // release the mouse button. //----------------------------------------------------------------------------- -static LRESULT CALLBACK MouseHook(int code, WPARAM wParam, LPARAM lParam) -{ - switch(code) { - case HC_ACTION: { - MSLLHOOKSTRUCT *mhs = (MSLLHOOKSTRUCT *)lParam; - - switch(wParam) { - case WM_MOUSEMOVE: { - int dy = MouseY - mhs->pt.y; +// static LRESULT CALLBACK MouseHook(int code, WPARAM wParam, LPARAM lParam) +// { +// switch(code) { +// case HC_ACTION: { +// MSLLHOOKSTRUCT *mhs = (MSLLHOOKSTRUCT *)lParam; + +// switch(wParam) { +// case WM_MOUSEMOVE: { +// int dy = MouseY - mhs->pt.y; - IoListHeight += dy; - if(IoListHeight < 50) IoListHeight = 50; - MouseY = mhs->pt.y; - MainWindowResized(); - - break; - } - - case WM_LBUTTONUP: - UnhookWindowsHookEx(MouseHookHandle); - break; - } - break; - } - } - return CallNextHookEx(MouseHookHandle, code, wParam, lParam); -} +// IoListHeight += dy; +// if(IoListHeight < 50) IoListHeight = 50; +// MouseY = mhs->pt.y; +// MainWindowResized(); + +// break; +// } + +// case WM_LBUTTONUP: +// UnhookWindowsHookEx(MouseHookHandle); +// break; +// } +// break; +// } +// } +// return CallNextHookEx(MouseHookHandle, code, wParam, lParam); +// } //----------------------------------------------------------------------------- // Handle a selection from the menu bar of the main window. //----------------------------------------------------------------------------- -static void ProcessMenu(int code) -{ - if(code >= MNU_PROCESSOR_0 && code < MNU_PROCESSOR_0+NUM_SUPPORTED_MCUS) { - strcpy(CurrentCompileFile, ""); - Prog.mcu = &SupportedMcus[code - MNU_PROCESSOR_0]; - RefreshControlsToSettings(); - return; - } - if(code == MNU_PROCESSOR_0+NUM_SUPPORTED_MCUS) { - Prog.mcu = NULL; - strcpy(CurrentCompileFile, ""); - RefreshControlsToSettings(); - return; - } - - switch(code) { - case MNU_NEW: - if(CheckSaveUserCancels()) break; - NewProgram(); - strcpy(CurrentSaveFile, ""); - strcpy(CurrentCompileFile, ""); - GenerateIoListDontLoseSelection(); - RefreshScrollbars(); - UpdateMainWindowTitleBar(); - break; - - case MNU_OPEN: - if(CheckSaveUserCancels()) break; - OpenDialog(); - break; - - case MNU_SAVE: - SaveProgram(); - UpdateMainWindowTitleBar(); - break; - - case MNU_SAVE_AS: - SaveAsDialog(); - UpdateMainWindowTitleBar(); - break; - - case MNU_EXPORT: - ExportDialog(); - break; - - case MNU_EXIT: - if(CheckSaveUserCancels()) break; - PostQuitMessage(0); - break; - - case MNU_INSERT_COMMENT: - CHANGING_PROGRAM(AddComment(_("--add comment here--"))); - break; - - case MNU_INSERT_CONTACTS: - CHANGING_PROGRAM(AddContact()); - break; - - case MNU_INSERT_COIL: - CHANGING_PROGRAM(AddCoil()); - break; - - case MNU_INSERT_TON: - CHANGING_PROGRAM(AddTimer(ELEM_TON)); - break; - - case MNU_INSERT_TOF: - CHANGING_PROGRAM(AddTimer(ELEM_TOF)); - break; - - case MNU_INSERT_RTO: - CHANGING_PROGRAM(AddTimer(ELEM_RTO)); - break; - - case MNU_INSERT_CTU: - CHANGING_PROGRAM(AddCounter(ELEM_CTU)); - break; - - case MNU_INSERT_CTD: - CHANGING_PROGRAM(AddCounter(ELEM_CTD)); - break; - - case MNU_INSERT_CTC: - CHANGING_PROGRAM(AddCounter(ELEM_CTC)); - break; - - case MNU_INSERT_RES: - CHANGING_PROGRAM(AddReset()); - break; - - case MNU_INSERT_OPEN: - CHANGING_PROGRAM(AddEmpty(ELEM_OPEN)); - break; - - case MNU_INSERT_SHORT: - CHANGING_PROGRAM(AddEmpty(ELEM_SHORT)); - break; - - case MNU_INSERT_MASTER_RLY: - CHANGING_PROGRAM(AddMasterRelay()); - break; - - case MNU_INSERT_SHIFT_REG: - CHANGING_PROGRAM(AddShiftRegister()); - break; - - case MNU_INSERT_LUT: - CHANGING_PROGRAM(AddLookUpTable()); - break; +// static void ProcessMenu(int code) +// { +// if(code >= MNU_PROCESSOR_0 && code < MNU_PROCESSOR_0+NUM_SUPPORTED_MCUS) { +// strcpy(CurrentCompileFile, ""); +// Prog.mcu = &SupportedMcus[code - MNU_PROCESSOR_0]; +// RefreshControlsToSettings(); +// return; +// } +// if(code == MNU_PROCESSOR_0+NUM_SUPPORTED_MCUS) { +// Prog.mcu = NULL; +// strcpy(CurrentCompileFile, ""); +// RefreshControlsToSettings(); +// return; +// } + +// switch(code) { +// case MNU_NEW: +// if(CheckSaveUserCancels()) break; +// NewProgram(); +// strcpy(CurrentSaveFile, ""); +// strcpy(CurrentCompileFile, ""); +// GenerateIoListDontLoseSelection(); +// RefreshScrollbars(); +// UpdateMainWindowTitleBar(); +// break; + +// case MNU_OPEN: +// if(CheckSaveUserCancels()) break; +// OpenDialog(); +// break; + +// case MNU_SAVE: +// SaveProgram(); +// UpdateMainWindowTitleBar(); +// break; + +// case MNU_SAVE_AS: +// SaveAsDialog(); +// UpdateMainWindowTitleBar(); +// break; + +// case MNU_EXPORT: +// ExportDialog(); +// break; + +// case MNU_EXIT: +// if(CheckSaveUserCancels()) break; +// PostQuitMessage(0); +// break; + +// case MNU_INSERT_COMMENT: +// CHANGING_PROGRAM(AddComment(_("--add comment here--"))); +// break; + +// case MNU_INSERT_CONTACTS: +// CHANGING_PROGRAM(AddContact()); +// break; + +// case MNU_INSERT_COIL: +// CHANGING_PROGRAM(AddCoil()); +// break; + +// case MNU_INSERT_TON: +// CHANGING_PROGRAM(AddTimer(ELEM_TON)); +// break; + +// case MNU_INSERT_TOF: +// CHANGING_PROGRAM(AddTimer(ELEM_TOF)); +// break; + +// case MNU_INSERT_RTO: +// CHANGING_PROGRAM(AddTimer(ELEM_RTO)); +// break; + +// case MNU_INSERT_CTU: +// CHANGING_PROGRAM(AddCounter(ELEM_CTU)); +// break; + +// case MNU_INSERT_CTD: +// CHANGING_PROGRAM(AddCounter(ELEM_CTD)); +// break; + +// case MNU_INSERT_CTC: +// CHANGING_PROGRAM(AddCounter(ELEM_CTC)); +// break; + +// case MNU_INSERT_RES: +// CHANGING_PROGRAM(AddReset()); +// break; + +// case MNU_INSERT_OPEN: +// CHANGING_PROGRAM(AddEmpty(ELEM_OPEN)); +// break; + +// case MNU_INSERT_SHORT: +// CHANGING_PROGRAM(AddEmpty(ELEM_SHORT)); +// break; + +// case MNU_INSERT_MASTER_RLY: +// CHANGING_PROGRAM(AddMasterRelay()); +// break; + +// case MNU_INSERT_SHIFT_REG: +// CHANGING_PROGRAM(AddShiftRegister()); +// break; + +// case MNU_INSERT_LUT: +// CHANGING_PROGRAM(AddLookUpTable()); +// break; - case MNU_INSERT_PWL: - CHANGING_PROGRAM(AddPiecewiseLinear()); - break; +// case MNU_INSERT_PWL: +// CHANGING_PROGRAM(AddPiecewiseLinear()); +// break; - case MNU_INSERT_FMTD_STR: - CHANGING_PROGRAM(AddFormattedString()); - break; - - case MNU_INSERT_OSR: - CHANGING_PROGRAM(AddEmpty(ELEM_ONE_SHOT_RISING)); - break; - - case MNU_INSERT_OSF: - CHANGING_PROGRAM(AddEmpty(ELEM_ONE_SHOT_FALLING)); - break; - - case MNU_INSERT_MOV: - CHANGING_PROGRAM(AddMove()); - break; - - case MNU_INSERT_SET_PWM: - CHANGING_PROGRAM(AddSetPwm()); - break; - - case MNU_INSERT_READ_ADC: - CHANGING_PROGRAM(AddReadAdc()); - break; - - case MNU_INSERT_UART_SEND: - CHANGING_PROGRAM(AddUart(ELEM_UART_SEND)); - break; - - case MNU_INSERT_UART_RECV: - CHANGING_PROGRAM(AddUart(ELEM_UART_RECV)); - break; - - case MNU_INSERT_PERSIST: - CHANGING_PROGRAM(AddPersist()); - break; - - { - int elem; - case MNU_INSERT_ADD: elem = ELEM_ADD; goto math; - case MNU_INSERT_SUB: elem = ELEM_SUB; goto math; - case MNU_INSERT_MUL: elem = ELEM_MUL; goto math; - case MNU_INSERT_DIV: elem = ELEM_DIV; goto math; -math: - CHANGING_PROGRAM(AddMath(elem)); - break; - } - - { - int elem; - case MNU_INSERT_EQU: elem = ELEM_EQU; goto cmp; - case MNU_INSERT_NEQ: elem = ELEM_NEQ; goto cmp; - case MNU_INSERT_GRT: elem = ELEM_GRT; goto cmp; - case MNU_INSERT_GEQ: elem = ELEM_GEQ; goto cmp; - case MNU_INSERT_LES: elem = ELEM_LES; goto cmp; - case MNU_INSERT_LEQ: elem = ELEM_LEQ; goto cmp; -cmp: - CHANGING_PROGRAM(AddCmp(elem)); - break; - } - - case MNU_MAKE_NORMAL: - CHANGING_PROGRAM(MakeNormalSelected()); - break; - - case MNU_NEGATE: - CHANGING_PROGRAM(NegateSelected()); - break; - - case MNU_MAKE_SET_ONLY: - CHANGING_PROGRAM(MakeSetOnlySelected()); - break; - - case MNU_MAKE_RESET_ONLY: - CHANGING_PROGRAM(MakeResetOnlySelected()); - break; - - case MNU_UNDO: - UndoUndo(); - break; - - case MNU_REDO: - UndoRedo(); - break; - - case MNU_INSERT_RUNG_BEFORE: - CHANGING_PROGRAM(InsertRung(FALSE)); - break; - - case MNU_INSERT_RUNG_AFTER: - CHANGING_PROGRAM(InsertRung(TRUE)); - break; - - case MNU_DELETE_RUNG: - CHANGING_PROGRAM(DeleteSelectedRung()); - break; - - case MNU_PUSH_RUNG_UP: - CHANGING_PROGRAM(PushRungUp()); - break; - - case MNU_PUSH_RUNG_DOWN: - CHANGING_PROGRAM(PushRungDown()); - break; - - case MNU_DELETE_ELEMENT: - CHANGING_PROGRAM(DeleteSelectedFromProgram()); - break; - - case MNU_MCU_SETTINGS: - CHANGING_PROGRAM(ShowConfDialog()); - break; - - case MNU_SIMULATION_MODE: - ToggleSimulationMode(); - ToggleAdvancedSimulationMode(); - break; - - case MNU_START_SIMULATION: - StartSimulation(); - StartAdvSimulation(); - break; - - case MNU_STOP_SIMULATION: - StopSimulation(); - StopAdvSimulation(); - break; - - case MNU_SINGLE_CYCLE: - SimulateOneCycle(TRUE); - break; - - case MNU_COMPILE: - CompileProgram(FALSE); - break; - - case MNU_COMPILE_AS: - CompileProgram(TRUE); - break; - - case MNU_MANUAL: - ShowHelpDialog(FALSE); - break; - - case MNU_ABOUT: - ShowHelpDialog(TRUE); - break; - - case MNU_ADV_SIMULATION: - ShowAdvancedDialog(); - } -} +// case MNU_INSERT_FMTD_STR: +// CHANGING_PROGRAM(AddFormattedString()); +// break; + +// case MNU_INSERT_OSR: +// CHANGING_PROGRAM(AddEmpty(ELEM_ONE_SHOT_RISING)); +// break; + +// case MNU_INSERT_OSF: +// CHANGING_PROGRAM(AddEmpty(ELEM_ONE_SHOT_FALLING)); +// break; + +// case MNU_INSERT_MOV: +// CHANGING_PROGRAM(AddMove()); +// break; + +// case MNU_INSERT_SET_PWM: +// CHANGING_PROGRAM(AddSetPwm()); +// break; + +// case MNU_INSERT_READ_ADC: +// CHANGING_PROGRAM(AddReadAdc()); +// break; + +// case MNU_INSERT_UART_SEND: +// CHANGING_PROGRAM(AddUart(ELEM_UART_SEND)); +// break; + +// case MNU_INSERT_UART_RECV: +// CHANGING_PROGRAM(AddUart(ELEM_UART_RECV)); +// break; + +// case MNU_INSERT_PERSIST: +// CHANGING_PROGRAM(AddPersist()); +// break; + +// { +// int elem; +// case MNU_INSERT_ADD: elem = ELEM_ADD; goto math; +// case MNU_INSERT_SUB: elem = ELEM_SUB; goto math; +// case MNU_INSERT_MUL: elem = ELEM_MUL; goto math; +// case MNU_INSERT_DIV: elem = ELEM_DIV; goto math; +// math: +// CHANGING_PROGRAM(AddMath(elem)); +// break; +// } + +// { +// int elem; +// case MNU_INSERT_EQU: elem = ELEM_EQU; goto cmp; +// case MNU_INSERT_NEQ: elem = ELEM_NEQ; goto cmp; +// case MNU_INSERT_GRT: elem = ELEM_GRT; goto cmp; +// case MNU_INSERT_GEQ: elem = ELEM_GEQ; goto cmp; +// case MNU_INSERT_LES: elem = ELEM_LES; goto cmp; +// case MNU_INSERT_LEQ: elem = ELEM_LEQ; goto cmp; +// cmp: +// CHANGING_PROGRAM(AddCmp(elem)); +// break; +// } + +// case MNU_MAKE_NORMAL: +// CHANGING_PROGRAM(MakeNormalSelected()); +// break; + +// case MNU_NEGATE: +// CHANGING_PROGRAM(NegateSelected()); +// break; + +// case MNU_MAKE_SET_ONLY: +// CHANGING_PROGRAM(MakeSetOnlySelected()); +// break; + +// case MNU_MAKE_RESET_ONLY: +// CHANGING_PROGRAM(MakeResetOnlySelected()); +// break; + +// case MNU_UNDO: +// UndoUndo(); +// break; + +// case MNU_REDO: +// UndoRedo(); +// break; + +// case MNU_INSERT_RUNG_BEFORE: +// CHANGING_PROGRAM(InsertRung(FALSE)); +// break; + +// case MNU_INSERT_RUNG_AFTER: +// CHANGING_PROGRAM(InsertRung(TRUE)); +// break; + +// case MNU_DELETE_RUNG: +// CHANGING_PROGRAM(DeleteSelectedRung()); +// break; + +// case MNU_PUSH_RUNG_UP: +// CHANGING_PROGRAM(PushRungUp()); +// break; + +// case MNU_PUSH_RUNG_DOWN: +// CHANGING_PROGRAM(PushRungDown()); +// break; + +// case MNU_DELETE_ELEMENT: +// CHANGING_PROGRAM(DeleteSelectedFromProgram()); +// break; + +// case MNU_MCU_SETTINGS: +// CHANGING_PROGRAM(ShowConfDialog()); +// break; + +// case MNU_SIMULATION_MODE: +// ToggleSimulationMode(); +// break; + +// case MNU_START_SIMULATION: +// StartSimulation(); +// break; + +// case MNU_STOP_SIMULATION: +// StopSimulation(); +// break; + +// case MNU_SINGLE_CYCLE: +// SimulateOneCycle(TRUE); +// break; + +// case MNU_COMPILE: +// CompileProgram(FALSE); +// break; + +// case MNU_COMPILE_AS: +// CompileProgram(TRUE); +// break; + +// case MNU_MANUAL: +// ShowHelpDialog(FALSE); +// break; + +// case MNU_ABOUT: +// ShowHelpDialog(TRUE); +// break; +// } +// } //----------------------------------------------------------------------------- // WndProc for MainWindow. //----------------------------------------------------------------------------- -LRESULT CALLBACK MainWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) -{ - switch (msg) { - case WM_ERASEBKGND: - break; - - case WM_SETFOCUS: - InvalidateRect(MainWindow, NULL, FALSE); - break; - - case WM_PAINT: { - PAINTSTRUCT ps; - Hdc = BeginPaint(hwnd, &ps); - - // This draws the schematic. - PaintWindow(); - - RECT r; - // Fill around the scroll bars - if(NeedHoriz) { - r.top = IoListTop - ScrollHeight - 2; - r.bottom = IoListTop - 2; - FillRect(Hdc, &r, (HBRUSH)GetStockObject(LTGRAY_BRUSH)); - } - GetClientRect(MainWindow, &r); - r.left = r.right - ScrollWidth - 2; - FillRect(Hdc, &r, (HBRUSH)GetStockObject(LTGRAY_BRUSH)); - - // Draw the splitter thing to grab to resize the I/O listview. - GetClientRect(MainWindow, &r); - r.top = IoListTop - 2; - r.bottom = IoListTop; - FillRect(Hdc, &r, (HBRUSH)GetStockObject(LTGRAY_BRUSH)); - r.top = IoListTop - 2; - r.bottom = IoListTop - 1; - FillRect(Hdc, &r, (HBRUSH)GetStockObject(WHITE_BRUSH)); - r.top = IoListTop; - r.bottom = IoListTop + 1; - FillRect(Hdc, &r, (HBRUSH)GetStockObject(DKGRAY_BRUSH)); - - EndPaint(hwnd, &ps); - return 1; - } - - case WM_KEYDOWN: { - if(wParam == 'M') { - if(GetAsyncKeyState(VK_CONTROL) & 0x8000) { - ToggleSimulationMode(); - ToggleAdvancedSimulationMode(); - break; - } - } else if(wParam == VK_TAB) { - SetFocus(IoList); - BlinkCursor(0, 0, 0, 0); - break; - } else if(wParam == VK_F1) { - ShowHelpDialog(FALSE); - break; - } - - if(wParam == 'A') { - if(GetAsyncKeyState(VK_CONTROL) & 0x8000) { - ShowAdvancedDialog(); - break; - } - } - - if(InSimulationMode) { - switch(wParam) { - case ' ': - SimulateOneCycle(TRUE); - break; - - case 'R': - if(GetAsyncKeyState(VK_CONTROL) & 0x8000) - StartSimulation(); - StartAdvSimulation(); - break; - - case 'H': - if(GetAsyncKeyState(VK_CONTROL) & 0x8000) - StopSimulation(); - StopAdvSimulation(); - break; - - case VK_DOWN: - if(ScrollYOffset < ScrollYOffsetMax) - ScrollYOffset++; - RefreshScrollbars(); - InvalidateRect(MainWindow, NULL, FALSE); - break; - - case VK_UP: - if(ScrollYOffset > 0) - ScrollYOffset--; - RefreshScrollbars(); - InvalidateRect(MainWindow, NULL, FALSE); - break; - - case VK_LEFT: - ScrollXOffset -= FONT_WIDTH; - if(ScrollXOffset < 0) ScrollXOffset = 0; - RefreshScrollbars(); - InvalidateRect(MainWindow, NULL, FALSE); - break; - - case VK_RIGHT: - ScrollXOffset += FONT_WIDTH; - if(ScrollXOffset >= ScrollXOffsetMax) - ScrollXOffset = ScrollXOffsetMax; - RefreshScrollbars(); - InvalidateRect(MainWindow, NULL, FALSE); - break; - - case VK_RETURN: - case VK_ESCAPE: - ToggleSimulationMode(); - break; - } - break; - } - - switch(wParam) { - case VK_F5: - CompileProgram(FALSE); - break; - - case VK_UP: - if(GetAsyncKeyState(VK_SHIFT) & 0x8000) { - CHANGING_PROGRAM(PushRungUp()); - } else { - MoveCursorKeyboard(wParam); - } - break; - - case VK_DOWN: - if(GetAsyncKeyState(VK_SHIFT) & 0x8000) { - CHANGING_PROGRAM(PushRungDown()); - } else { - MoveCursorKeyboard(wParam); - } - break; - - case VK_RIGHT: - case VK_LEFT: - MoveCursorKeyboard(wParam); - break; - - case VK_RETURN: - CHANGING_PROGRAM(EditSelectedElement()); - break; - - case VK_DELETE: - if(GetAsyncKeyState(VK_SHIFT) & 0x8000) { - CHANGING_PROGRAM(DeleteSelectedRung()); - } else { - CHANGING_PROGRAM(DeleteSelectedFromProgram()); - } - break; - - case VK_OEM_1: - CHANGING_PROGRAM(AddComment(_("--add comment here--"))); - break; - - case 'C': - CHANGING_PROGRAM(AddContact()); - break; - - // TODO: rather country-specific here - case VK_OEM_2: - CHANGING_PROGRAM(AddEmpty(ELEM_ONE_SHOT_RISING)); - break; - - case VK_OEM_5: - CHANGING_PROGRAM(AddEmpty(ELEM_ONE_SHOT_FALLING)); - break; - - case 'L': - CHANGING_PROGRAM(AddCoil()); - break; - - case 'R': - CHANGING_PROGRAM(MakeResetOnlySelected()); - break; - - case 'E': - if(GetAsyncKeyState(VK_CONTROL) & 0x8000) { - ExportDialog(); - } else { - CHANGING_PROGRAM(AddReset()); - } - break; - - case 'S': - if(GetAsyncKeyState(VK_CONTROL) & 0x8000) { - SaveProgram(); - UpdateMainWindowTitleBar(); - } else { - CHANGING_PROGRAM(MakeSetOnlySelected()); - } - break; - - case 'N': - if(GetAsyncKeyState(VK_CONTROL) & 0x8000) { - if(CheckSaveUserCancels()) break; - if(!ProgramChangedNotSaved) { - int r = MessageBox(MainWindow, - _("Start new program?"), - "LDmicro", MB_YESNO | MB_DEFBUTTON2 | - MB_ICONQUESTION); - if(r == IDNO) break; - } - NewProgram(); - strcpy(CurrentSaveFile, ""); - strcpy(CurrentCompileFile, ""); - GenerateIoListDontLoseSelection(); - RefreshScrollbars(); - UpdateMainWindowTitleBar(); - } else { - CHANGING_PROGRAM(NegateSelected()); - } - break; - - case 'A': - CHANGING_PROGRAM(MakeNormalSelected()); - break; - - case 'T': - CHANGING_PROGRAM(AddTimer(ELEM_RTO)); - break; - - case 'O': - if(GetAsyncKeyState(VK_CONTROL) & 0x8000) { - if(CheckSaveUserCancels()) break; - OpenDialog(); - } else { - CHANGING_PROGRAM(AddTimer(ELEM_TON)); - } - break; - - case 'F': - CHANGING_PROGRAM(AddTimer(ELEM_TOF)); - break; - - case 'U': - CHANGING_PROGRAM(AddCounter(ELEM_CTU)); - break; - - case 'I': - CHANGING_PROGRAM(AddCounter(ELEM_CTD)); - break; - - case 'J': - CHANGING_PROGRAM(AddCounter(ELEM_CTC)); - break; - - case 'M': - CHANGING_PROGRAM(AddMove()); - break; - - case 'P': - CHANGING_PROGRAM(AddReadAdc()); - break; - - case VK_OEM_PLUS: - if(GetAsyncKeyState(VK_SHIFT) & 0x8000) { - CHANGING_PROGRAM(AddMath(ELEM_ADD)); - } else { - CHANGING_PROGRAM(AddCmp(ELEM_EQU)); - } - break; - - case VK_OEM_MINUS: - if(GetAsyncKeyState(VK_SHIFT) & 0x8000) { - } else { - CHANGING_PROGRAM(AddMath(ELEM_SUB)); - } - break; - - case '8': - if(GetAsyncKeyState(VK_SHIFT) & 0x8000) { - CHANGING_PROGRAM(AddMath(ELEM_MUL)); - } - break; - - case 'D': - CHANGING_PROGRAM(AddMath(ELEM_DIV)); - break; - - case VK_OEM_PERIOD: - if(GetAsyncKeyState(VK_SHIFT) & 0x8000) { - CHANGING_PROGRAM(AddCmp(ELEM_GRT)); - } else { - CHANGING_PROGRAM(AddCmp(ELEM_GEQ)); - } - break; - - case VK_OEM_COMMA: - if(GetAsyncKeyState(VK_SHIFT) & 0x8000) { - CHANGING_PROGRAM(AddCmp(ELEM_LES)); - } else { - CHANGING_PROGRAM(AddCmp(ELEM_LEQ)); - } - break; - - case 'V': - if(GetAsyncKeyState(VK_SHIFT) & 0x8000) { - CHANGING_PROGRAM(InsertRung(TRUE)); - } - break; - - case '6': - if(GetAsyncKeyState(VK_SHIFT) & 0x8000) { - CHANGING_PROGRAM(InsertRung(FALSE)); - } - break; - - case 'Z': - if(GetAsyncKeyState(VK_CONTROL) & 0x8000) { - UndoUndo(); - } - break; - - case 'Y': - if(GetAsyncKeyState(VK_CONTROL) & 0x8000) { - UndoRedo(); - } - break; - - default: - break; - } - if(wParam != VK_SHIFT && wParam != VK_CONTROL) { - InvalidateRect(MainWindow, NULL, FALSE); - } - break; - } - - case WM_LBUTTONDBLCLK: { - int x = LOWORD(lParam); - int y = HIWORD(lParam); - if(InSimulationMode) { - EditElementMouseDoubleclick(x, y); - } else { - CHANGING_PROGRAM(EditElementMouseDoubleclick(x, y)); - } - InvalidateRect(MainWindow, NULL, FALSE); - break; - } - - case WM_LBUTTONDOWN: { - int x = LOWORD(lParam); - int y = HIWORD(lParam); - if((y > (IoListTop - 9)) && (y < (IoListTop + 3))) { - POINT pt; - pt.x = x; pt.y = y; - ClientToScreen(MainWindow, &pt); - MouseY = pt.y; - MouseHookHandle = SetWindowsHookEx(WH_MOUSE_LL, - (HOOKPROC)MouseHook, Instance, 0); - } - if(!InSimulationMode) MoveCursorMouseClick(x, y); - - SetFocus(MainWindow); - InvalidateRect(MainWindow, NULL, FALSE); - break; - } - case WM_MOUSEMOVE: { - int x = LOWORD(lParam); - int y = HIWORD(lParam); - - if((y > (IoListTop - 9)) && (y < (IoListTop + 3))) { - SetCursor(LoadCursor(NULL, IDC_SIZENS)); - } else { - SetCursor(LoadCursor(NULL, IDC_ARROW)); - } +// LRESULT CALLBACK MainWndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) +// { +// switch (msg) { +// case WM_ERASEBKGND: +// break; + +// case WM_SETFOCUS: +// InvalidateRect(MainWindow, NULL, FALSE); +// break; + +// case WM_PAINT: { +// PAINTSTRUCT ps; +// Hdc = BeginPaint(hwnd, &ps); + +// // This draws the schematic. +// PaintWindow(); + +// RECT r; +// // Fill around the scroll bars +// if(NeedHoriz) { +// r.top = IoListTop - ScrollHeight - 2; +// r.bottom = IoListTop - 2; +// FillRect(Hdc, &r, (HBRUSH)GetStockObject(LTGRAY_BRUSH)); +// } +// GetClientRect(MainWindow, &r); +// r.left = r.right - ScrollWidth - 2; +// FillRect(Hdc, &r, (HBRUSH)GetStockObject(LTGRAY_BRUSH)); + +// // Draw the splitter thing to grab to resize the I/O listview. +// GetClientRect(MainWindow, &r); +// r.top = IoListTop - 2; +// r.bottom = IoListTop; +// FillRect(Hdc, &r, (HBRUSH)GetStockObject(LTGRAY_BRUSH)); +// r.top = IoListTop - 2; +// r.bottom = IoListTop - 1; +// FillRect(Hdc, &r, (HBRUSH)GetStockObject(WHITE_BRUSH)); +// r.top = IoListTop; +// r.bottom = IoListTop + 1; +// FillRect(Hdc, &r, (HBRUSH)GetStockObject(DKGRAY_BRUSH)); + +// EndPaint(hwnd, &ps); +// return 1; +// } + +// case WM_KEYDOWN: { +// if(wParam == 'M') { +// if(GetAsyncKeyState(VK_CONTROL) & 0x8000) { +// ToggleSimulationMode(); +// break; +// } +// } else if(wParam == VK_TAB) { +// SetFocus(IoList); +// BlinkCursor(0, 0, 0, 0); +// break; +// } else if(wParam == VK_F1) { +// ShowHelpDialog(FALSE); +// break; +// } + +// if(InSimulationMode) { +// switch(wParam) { +// case ' ': +// SimulateOneCycle(TRUE); +// break; + +// case 'R': +// if(GetAsyncKeyState(VK_CONTROL) & 0x8000) +// StartSimulation(); +// break; + +// case 'H': +// if(GetAsyncKeyState(VK_CONTROL) & 0x8000) +// StopSimulation(); +// break; + +// case VK_DOWN: +// if(ScrollYOffset < ScrollYOffsetMax) +// ScrollYOffset++; +// RefreshScrollbars(); +// InvalidateRect(MainWindow, NULL, FALSE); +// break; + +// case VK_UP: +// if(ScrollYOffset > 0) +// ScrollYOffset--; +// RefreshScrollbars(); +// InvalidateRect(MainWindow, NULL, FALSE); +// break; + +// case VK_LEFT: +// ScrollXOffset -= FONT_WIDTH; +// if(ScrollXOffset < 0) ScrollXOffset = 0; +// RefreshScrollbars(); +// InvalidateRect(MainWindow, NULL, FALSE); +// break; + +// case VK_RIGHT: +// ScrollXOffset += FONT_WIDTH; +// if(ScrollXOffset >= ScrollXOffsetMax) +// ScrollXOffset = ScrollXOffsetMax; +// RefreshScrollbars(); +// InvalidateRect(MainWindow, NULL, FALSE); +// break; + +// case VK_RETURN: +// case VK_ESCAPE: +// ToggleSimulationMode(); +// break; +// } +// break; +// } + + +// switch(wParam) { +// case VK_F5: +// CompileProgram(FALSE); +// break; + +// case VK_UP: +// if(GetAsyncKeyState(VK_SHIFT) & 0x8000) { +// CHANGING_PROGRAM(PushRungUp()); +// } else { +// MoveCursorKeyboard(wParam); +// } +// break; + +// case VK_DOWN: +// if(GetAsyncKeyState(VK_SHIFT) & 0x8000) { +// CHANGING_PROGRAM(PushRungDown()); +// } else { +// MoveCursorKeyboard(wParam); +// } +// break; + +// case VK_RIGHT: +// case VK_LEFT: +// MoveCursorKeyboard(wParam); +// break; + +// case VK_RETURN: +// CHANGING_PROGRAM(EditSelectedElement()); +// break; + +// case VK_DELETE: +// if(GetAsyncKeyState(VK_SHIFT) & 0x8000) { +// CHANGING_PROGRAM(DeleteSelectedRung()); +// } else { +// CHANGING_PROGRAM(DeleteSelectedFromProgram()); +// } +// break; + +// case VK_OEM_1: +// CHANGING_PROGRAM(AddComment(_("--add comment here--"))); +// break; + +// case 'C': +// CHANGING_PROGRAM(AddContact()); +// break; + +// // TODO: rather country-specific here +// case VK_OEM_2: +// CHANGING_PROGRAM(AddEmpty(ELEM_ONE_SHOT_RISING)); +// break; + +// case VK_OEM_5: +// CHANGING_PROGRAM(AddEmpty(ELEM_ONE_SHOT_FALLING)); +// break; + +// case 'L': +// CHANGING_PROGRAM(AddCoil()); +// break; + +// case 'R': +// CHANGING_PROGRAM(MakeResetOnlySelected()); +// break; + +// case 'E': +// if(GetAsyncKeyState(VK_CONTROL) & 0x8000) { +// ExportDialog(); +// } else { +// CHANGING_PROGRAM(AddReset()); +// } +// break; + +// case 'S': +// if(GetAsyncKeyState(VK_CONTROL) & 0x8000) { +// SaveProgram(); +// UpdateMainWindowTitleBar(); +// } else { +// CHANGING_PROGRAM(MakeSetOnlySelected()); +// } +// break; + +// case 'N': +// if(GetAsyncKeyState(VK_CONTROL) & 0x8000) { +// if(CheckSaveUserCancels()) break; +// if(!ProgramChangedNotSaved) { +// int r = MessageBox(MainWindow, +// _("Start new program?"), +// "LDmicro", MB_YESNO | MB_DEFBUTTON2 | +// MB_ICONQUESTION); +// if(r == IDNO) break; +// } +// NewProgram(); +// strcpy(CurrentSaveFile, ""); +// strcpy(CurrentCompileFile, ""); +// GenerateIoListDontLoseSelection(); +// RefreshScrollbars(); +// UpdateMainWindowTitleBar(); +// } else { +// CHANGING_PROGRAM(NegateSelected()); +// } +// break; + +// case 'A': +// CHANGING_PROGRAM(MakeNormalSelected()); +// break; + +// case 'T': +// CHANGING_PROGRAM(AddTimer(ELEM_RTO)); +// break; + +// case 'O': +// if(GetAsyncKeyState(VK_CONTROL) & 0x8000) { +// if(CheckSaveUserCancels()) break; +// OpenDialog(); +// } else { +// CHANGING_PROGRAM(AddTimer(ELEM_TON)); +// } +// break; + +// case 'F': +// CHANGING_PROGRAM(AddTimer(ELEM_TOF)); +// break; + +// case 'U': +// CHANGING_PROGRAM(AddCounter(ELEM_CTU)); +// break; + +// case 'I': +// CHANGING_PROGRAM(AddCounter(ELEM_CTD)); +// break; + +// case 'J': +// CHANGING_PROGRAM(AddCounter(ELEM_CTC)); +// break; + +// case 'M': +// CHANGING_PROGRAM(AddMove()); +// break; + +// case 'P': +// CHANGING_PROGRAM(AddReadAdc()); +// break; + +// case VK_OEM_PLUS: +// if(GetAsyncKeyState(VK_SHIFT) & 0x8000) { +// CHANGING_PROGRAM(AddMath(ELEM_ADD)); +// } else { +// CHANGING_PROGRAM(AddCmp(ELEM_EQU)); +// } +// break; + +// case VK_OEM_MINUS: +// if(GetAsyncKeyState(VK_SHIFT) & 0x8000) { +// } else { +// CHANGING_PROGRAM(AddMath(ELEM_SUB)); +// } +// break; + +// case '8': +// if(GetAsyncKeyState(VK_SHIFT) & 0x8000) { +// CHANGING_PROGRAM(AddMath(ELEM_MUL)); +// } +// break; + +// case 'D': +// CHANGING_PROGRAM(AddMath(ELEM_DIV)); +// break; + +// case VK_OEM_PERIOD: +// if(GetAsyncKeyState(VK_SHIFT) & 0x8000) { +// CHANGING_PROGRAM(AddCmp(ELEM_GRT)); +// } else { +// CHANGING_PROGRAM(AddCmp(ELEM_GEQ)); +// } +// break; + +// case VK_OEM_COMMA: +// if(GetAsyncKeyState(VK_SHIFT) & 0x8000) { +// CHANGING_PROGRAM(AddCmp(ELEM_LES)); +// } else { +// CHANGING_PROGRAM(AddCmp(ELEM_LEQ)); +// } +// break; + +// case 'V': +// if(GetAsyncKeyState(VK_SHIFT) & 0x8000) { +// CHANGING_PROGRAM(InsertRung(TRUE)); +// } +// break; + +// case '6': +// if(GetAsyncKeyState(VK_SHIFT) & 0x8000) { +// CHANGING_PROGRAM(InsertRung(FALSE)); +// } +// break; + +// case 'Z': +// if(GetAsyncKeyState(VK_CONTROL) & 0x8000) { +// UndoUndo(); +// } +// break; + +// case 'Y': +// if(GetAsyncKeyState(VK_CONTROL) & 0x8000) { +// UndoRedo(); +// } +// break; + +// default: +// break; +// } +// if(wParam != VK_SHIFT && wParam != VK_CONTROL) { +// InvalidateRect(MainWindow, NULL, FALSE); +// } +// break; +// } + +// case WM_LBUTTONDBLCLK: { +// int x = LOWORD(lParam); +// int y = HIWORD(lParam); +// if(InSimulationMode) { +// EditElementMouseDoubleclick(x, y); +// } else { +// CHANGING_PROGRAM(EditElementMouseDoubleclick(x, y)); +// } +// InvalidateRect(MainWindow, NULL, FALSE); +// break; +// } + +// case WM_LBUTTONDOWN: { +// int x = LOWORD(lParam); +// int y = HIWORD(lParam); +// if((y > (IoListTop - 9)) && (y < (IoListTop + 3))) { +// POINT pt; +// pt.x = x; pt.y = y; +// ClientToScreen(MainWindow, &pt); +// MouseY = pt.y; +// MouseHookHandle = SetWindowsHookEx(WH_MOUSE_LL, +// (HOOKPROC)MouseHook, Instance, 0); +// } +// if(!InSimulationMode) MoveCursorMouseClick(x, y); + +// SetFocus(MainWindow); +// InvalidateRect(MainWindow, NULL, FALSE); +// break; +// } +// case WM_MOUSEMOVE: { +// int x = LOWORD(lParam); +// int y = HIWORD(lParam); + +// if((y > (IoListTop - 9)) && (y < (IoListTop + 3))) { +// SetCursor(LoadCursor(NULL, IDC_SIZENS)); +// } else { +// SetCursor(LoadCursor(NULL, IDC_ARROW)); +// } - break; - } - case WM_MOUSEWHEEL: { - if((GET_WHEEL_DELTA_WPARAM(wParam)) > 0) { - VscrollProc(SB_LINEUP); - } else { - VscrollProc(SB_LINEDOWN); - } - break; - } - - case WM_SIZE: - MainWindowResized(); - break; - - case WM_NOTIFY: { - NMHDR *h = (NMHDR *)lParam; - if(h->hwndFrom == IoList) { - IoListProc(h); - } - return 0; - } - case WM_VSCROLL: - VscrollProc(wParam); - break; - - case WM_HSCROLL: - HscrollProc(wParam); - break; - - case WM_COMMAND: - ProcessMenu(LOWORD(wParam)); - InvalidateRect(MainWindow, NULL, FALSE); - break; - - case WM_CLOSE: - case WM_DESTROY: - if(CheckSaveUserCancels()) break; - - PostQuitMessage(0); - return 1; - default: - return DefWindowProc(hwnd, msg, wParam, lParam); - } - - return 1; -} +// break; +// } +// case WM_MOUSEWHEEL: { +// if((GET_WHEEL_DELTA_WPARAM(wParam)) > 0) { +// VscrollProc(SB_LINEUP); +// } else { +// VscrollProc(SB_LINEDOWN); +// } +// break; +// } + +// case WM_SIZE: +// MainWindowResized(); +// break; + +// case WM_NOTIFY: { +// NMHDR *h = (NMHDR *)lParam; +// if(h->hwndFrom == IoList) { +// IoListProc(h); +// } +// return 0; +// } +// case WM_VSCROLL: +// VscrollProc(wParam); +// break; + +// case WM_HSCROLL: +// HscrollProc(wParam); +// break; + +// case WM_COMMAND: +// ProcessMenu(LOWORD(wParam)); +// InvalidateRect(MainWindow, NULL, FALSE); +// break; + +// case WM_CLOSE: +// case WM_DESTROY: +// if(CheckSaveUserCancels()) break; + +// PostQuitMessage(0); +// return 1; + +// default: +// return DefWindowProc(hwnd, msg, wParam, lParam); +// } + +// return 1; +// } //----------------------------------------------------------------------------- // Create our window class; nothing exciting. //----------------------------------------------------------------------------- -static BOOL MakeWindowClass() -{ - WNDCLASSEX wc; - memset(&wc, 0, sizeof(wc)); - wc.cbSize = sizeof(wc); - - wc.style = CS_BYTEALIGNCLIENT | CS_BYTEALIGNWINDOW | CS_OWNDC | - CS_DBLCLKS; - wc.lpfnWndProc = (WNDPROC)MainWndProc; - wc.hInstance = Instance; - wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); - wc.lpszClassName = "LDmicro"; - wc.lpszMenuName = NULL; - wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.hIcon = (HICON)LoadImage(Instance, MAKEINTRESOURCE(4000), - IMAGE_ICON, 32, 32, 0); - wc.hIconSm = (HICON)LoadImage(Instance, MAKEINTRESOURCE(4000), - IMAGE_ICON, 16, 16, 0); - - return RegisterClassEx(&wc); -} +// static BOOL MakeWindowClass() +// { +// WNDCLASSEX wc; +// memset(&wc, 0, sizeof(wc)); +// wc.cbSize = sizeof(wc); + +// wc.style = CS_BYTEALIGNCLIENT | CS_BYTEALIGNWINDOW | CS_OWNDC | +// CS_DBLCLKS; +// wc.lpfnWndProc = (WNDPROC)MainWndProc; +// wc.hInstance = Instance; +// wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); +// wc.lpszClassName = "LDmicro"; +// wc.lpszMenuName = NULL; +// wc.hCursor = LoadCursor(NULL, IDC_ARROW); +// wc.hIcon = (HICON)LoadImage(Instance, MAKEINTRESOURCE(4000), +// IMAGE_ICON, 32, 32, 0); +// wc.hIconSm = (HICON)LoadImage(Instance, MAKEINTRESOURCE(4000), +// IMAGE_ICON, 16, 16, 0); + +// return RegisterClassEx(&wc); +// } //----------------------------------------------------------------------------- // Entry point into the program. //----------------------------------------------------------------------------- int main(int argc, char** argv) { - // Check if we're running in non-interactive mode; in that case we should - // load the file, compile, and exit. + /// Check if we're running in non-interactive mode; in that case we should + /// load the file, compile, and exit. + if(argc >= 2) { RunningInBatchMode = TRUE; char *err = "Bad command line arguments: run 'ldmicro /c src.ld dest.hex'"; - char *source = lpCmdLine + 2; + if (argc < 4) + { + printf("throwing error...\n"); + Error(err); + exit(-1); + } + + char *source = (char*)malloc(strlen(argv[2]) + strlen(argv[3]) + 2); + sprintf(source, "%s %s", argv[2], argv[3]); + while(isspace(*source)) { source++; } - if(*source == '\0') { Error(err); exit(-1); } + if(*source == '\0') + { + Error(err); + free(source); + exit(-1); + } + char *dest = source; while(!isspace(*dest) && *dest) { dest++; } - if(*dest == '\0') { Error(err); exit(-1); } + if(*dest == '\0') + { + Error(err); + free(source); + exit(-1); + } *dest = '\0'; dest++; while(isspace(*dest)) { dest++; } - if(*dest == '\0') { Error(err); exit(-1); } + + if(*dest == '\0') + { + Error(err); + free(source); + exit(-1); + } + if(!LoadProjectFromFile(source)) { - Error("Couldn't open '%s', running non-interactively.", source); + Error("Couldn't open '%s', running non-interactively.\n", source); + free(source); exit(-1); } strcpy(CurrentCompileFile, dest); @@ -1086,89 +1094,87 @@ int main(int argc, char** argv) exit(0); } - /// ~~~ - Instance = hInstance; - - MainHeap = HeapCreate(0, 1024*64, 0); - - // MakeWindowClass(); - // MakeDialogBoxClass(); - // MakeAdvancedDialogClass(); - // MakeAdvancedWorkspaceClass(); - // MakeComponentListClass(); - // MakeSmplDialogClass(); - // MakeNamingListClass(); - HMENU top = MakeMainWindowMenus(); - - /// Make main window - // MainWindow = CreateWindowEx(0, "LDmicro", "", - // WS_OVERLAPPED | WS_THICKFRAME | WS_CLIPCHILDREN | WS_MAXIMIZEBOX | - // WS_MINIMIZEBOX | WS_SYSMENU | WS_SIZEBOX, - // 10, 10, 800, 600, NULL, top, Instance, NULL); - ThawWindowPos(MainWindow); - IoListHeight = 100; - ThawDWORD(IoListHeight); - - InitCommonControls(); - InitForDrawing(); - - MakeMainWindowControls(); - MainWindowResized(); - NewProgram(); - strcpy(CurrentSaveFile, ""); - - // We are running interactively, or we would already have exited. We - // can therefore show the window now, and otherwise set up the GUI. - - ShowWindow(MainWindow, SW_SHOW); - SetTimer(MainWindow, TIMER_BLINK_CURSOR, 800, BlinkCursor); - - if(strlen(lpCmdLine) > 0) { - char line[MAX_PATH]; - if(*lpCmdLine == '"') { - strcpy(line, lpCmdLine+1); - } else { - strcpy(line, lpCmdLine); - } - if(strchr(line, '"')) *strchr(line, '"') = '\0'; - - char *s; - GetFullPathName(line, sizeof(CurrentSaveFile), CurrentSaveFile, &s); - if(!LoadProjectFromFile(CurrentSaveFile)) { - NewProgram(); - Error(_("Couldn't open '%s'."), CurrentSaveFile); - CurrentSaveFile[0] = '\0'; - } - UndoFlush(); - } + // /// ~~~ + // Instance = hInstance; /// parent window - GenerateIoListDontLoseSelection(); - RefreshScrollbars(); - UpdateMainWindowTitleBar(); - - MSG msg; - DWORD ret; - while(ret = GetMessage(&msg, NULL, 0, 0)) { - if(msg.hwnd == IoList && msg.message == WM_KEYDOWN) { - if(msg.wParam == VK_TAB) { - SetFocus(MainWindow); - continue; - } - } - if(msg.message == WM_KEYDOWN && msg.wParam != VK_UP && - msg.wParam != VK_DOWN && msg.wParam != VK_RETURN && msg.wParam - != VK_SHIFT) - { - if(msg.hwnd == IoList) { - msg.hwnd = MainWindow; - SetFocus(MainWindow); - } - } - TranslateMessage(&msg); - DispatchMessage(&msg); - } - FreezeWindowPos(MainWindow); - FreezeDWORD(IoListHeight); + // MainHeap = HeapCreate(0, 1024*64, 0); + + // // MakeWindowClass(); + // // MakeDialogBoxClass(); + // // MakeComponentListClass(); + // // MakeSmplDialogClass(); + // // MakeNamingListClass(); + // HMENU top = MakeMainWindowMenus(); + + // /// Make main window + // // MainWindow = CreateWindowEx(0, "LDmicro", "", + // // WS_OVERLAPPED | WS_THICKFRAME | WS_CLIPCHILDREN | WS_MAXIMIZEBOX | + // // WS_MINIMIZEBOX | WS_SYSMENU | WS_SIZEBOX, + // // 10, 10, 800, 600, NULL, top, Instance, NULL); + // ThawWindowPos(MainWindow); + // IoListHeight = 100; + // ThawDWORD(IoListHeight); + + // InitCommonControls(); + // InitForDrawing(); + + // MakeMainWindowControls(); + // MainWindowResized(); + // NewProgram(); + // strcpy(CurrentSaveFile, ""); + + // // We are running interactively, or we would already have exited. We + // // can therefore show the window now, and otherwise set up the GUI. + + // ShowWindow(MainWindow, SW_SHOW); + // SetTimer(MainWindow, TIMER_BLINK_CURSOR, 800, BlinkCursor); + + // if(strlen(lpCmdLine) > 0) { + // char line[MAX_PATH]; + // if(*lpCmdLine == '"') { + // strcpy(line, lpCmdLine+1); + // } else { + // strcpy(line, lpCmdLine); + // } + // if(strchr(line, '"')) *strchr(line, '"') = '\0'; + + // char *s; + // GetFullPathName(line, sizeof(CurrentSaveFile), CurrentSaveFile, &s); + // if(!LoadProjectFromFile(CurrentSaveFile)) { + // NewProgram(); + // Error(_("Couldn't open '%s'."), CurrentSaveFile); + // CurrentSaveFile[0] = '\0'; + // } + // UndoFlush(); + // } + + // GenerateIoListDontLoseSelection(); + // RefreshScrollbars(); + // UpdateMainWindowTitleBar(); + + // MSG msg; + // DWORD ret; + // while(ret = GetMessage(&msg, NULL, 0, 0)) { + // if(msg.hwnd == IoList && msg.message == WM_KEYDOWN) { + // if(msg.wParam == VK_TAB) { + // SetFocus(MainWindow); + // continue; + // } + // } + // if(msg.message == WM_KEYDOWN && msg.wParam != VK_UP && + // msg.wParam != VK_DOWN && msg.wParam != VK_RETURN && msg.wParam + // != VK_SHIFT) + // { + // if(msg.hwnd == IoList) { + // msg.hwnd = MainWindow; + // SetFocus(MainWindow); + // } + // } + // TranslateMessage(&msg); + // DispatchMessage(&msg); + // } + // FreezeWindowPos(MainWindow); + // FreezeDWORD(IoListHeight); return 0; } diff --git a/ldmicro/ldmicro.exe.manifest b/ldmicro/ldmicro.exe.manifest deleted file mode 100644 index ee71fe3..0000000 --- a/ldmicro/ldmicro.exe.manifest +++ /dev/null @@ -1,22 +0,0 @@ -<?xml version="1.0" encoding="UTF-8" standalone="yes"?> -<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> -<assemblyIdentity - version="1.0.0.0" - processorArchitecture="X86" - name="JonathanWesthues.LadderLogic.LDMicro" - type="win32" -/> -<description>Ladder logic editor/compiler for PIC and AVR micros.</description> -<dependency> - <dependentAssembly> - <assemblyIdentity - type="win32" - name="Microsoft.Windows.Common-Controls" - version="6.0.0.0" - processorArchitecture="X86" - publicKeyToken="6595b64144ccf1df" - language="*" - /> - </dependentAssembly> -</dependency> -</assembly> diff --git a/ldmicro/ldmicro.rc b/ldmicro/ldmicro.rc deleted file mode 100644 index 952b087..0000000 --- a/ldmicro/ldmicro.rc +++ /dev/null @@ -1,19 +0,0 @@ - -// we need a manifest if we want visual styles; put in numbers since somethings a bit screwy -// with my SDK install (I don't think I've got *.rh right) - -#include "components/componentimages.h" - -1 24 "ldmicro.exe.manifest" - -4000 ICON "ldmicro.ico" -RELAY_NC PNG "img\\relay_nc.png" -RELAY_NO PNG "img\\relay_no.png" -SWITCH_CONNECTED PNG "img\\switch_connected.png" -SWITCH_DISCONNECTED PNG "img\\switch_disconnected.png" -SPDT_1 PNG "img\\spdt_1.png" -SPDT_2 PNG "img\\spdt_2.png" -DPST_1 PNG "img\\dpst_1.png" -DPST_2 PNG "img\\dpst_2.png" -DPDT_1 PNG "img\\dpdt_1.png" -DPDT_2 PNG "img\\dpdt_2.png" diff --git a/ldmicro/lib/linuxUI/linuxLD.cpp b/ldmicro/lib/linuxUI/linuxLD.cpp index 69c5f6e..e4fd018 100644 --- a/ldmicro/lib/linuxUI/linuxLD.cpp +++ b/ldmicro/lib/linuxUI/linuxLD.cpp @@ -1,2 +1,114 @@ #include "linuxUI.h" +std::vector<HEAPRECORD> HeapRecords; + +HANDLE HeapCreate(DWORD flOptions, SIZE_T dwInitialSize, SIZE_T dwMaximumSize) +{ + HANDLE hHeap = NULL; + HEAPRECORD hHeapRecord; + hHeapRecord.dwMaximumSize = dwMaximumSize; + hHeap = malloc(dwInitialSize); + + if (hHeap == NULL) + return NULL; + + hHeapRecord.dwSize = dwInitialSize; + hHeapRecord.hHeap = hHeap; + hHeapRecord.dwAllocatedSizeOffset = 0; + hHeapRecord.HeapID = HeapRecords.size()+1; + HeapRecords.push_back(hHeapRecord); + + return hHeap; +} + +LPVOID HeapAlloc(HANDLE hHeap, DWORD dwFlags, SIZE_T dwBytes) +{ + if (hHeap == NULL) + { + printf("Alloc**********NULL HEAP***************\n"); + LPVOID p = malloc(dwBytes); + return p; + } + + auto it = std::find_if(HeapRecords.begin(), HeapRecords.end(), [&hHeap](HEAPRECORD &Record) { return Record.hHeap == hHeap; }); + + if (it == HeapRecords.end()) + return NULL; + + if ((*it).dwAllocatedSizeOffset + dwBytes > (*it).dwSize) + { + if ((*it).dwMaximumSize != 0) + if((*it).dwAllocatedSizeOffset + dwBytes > (*it).dwMaximumSize) + return NULL; + + (*it).hHeap = realloc((*it).hHeap, (*it).dwAllocatedSizeOffset + dwBytes); + hHeap = (*it).hHeap; + } + + /// HEAP_ZERO_MEMORY is set by default + DWORD flags = MAP_ANONYMOUS; + + // if ( !((dwFlags & HEAP_ZERO_MEMORY) == HEAP_ZERO_MEMORY) ) + // flags = MAP_ANONYMOUS | MAP_UNINITIALIZED; + + /* Use for setting a meamory chunck with some value + * void * memset ( void * ptr, int value, size_t num ); + */ + LPVOID p = mmap(hHeap + (*it).dwAllocatedSizeOffset, dwBytes, PROT_EXEC, flags, -1, 0); + + if (p == NULL) + return NULL; + + (*it).dwAllocatedSizeOffset += dwBytes; + HEAPCHUNCK chunck; + chunck.Chunck = p; + chunck.dwSize = dwBytes; + (*it).Element.push_back(chunck); + + return p; +} + +BOOL HeapFree(HANDLE hHeap, DWORD dwFlags, LPVOID lpMem) +{ + /// if NULL free() + if (hHeap == NULL) + { + printf("free*********NULL HEAP***************\n"); + free(lpMem); + return TRUE; + } + auto heap_it = std::find_if(HeapRecords.begin(), HeapRecords.end(), [&hHeap](HEAPRECORD &Record) { return Record.hHeap == hHeap; }); + + if (heap_it == HeapRecords.end()) + return FALSE; + + auto chunck_it = std::find_if((*heap_it).Element.begin(), (*heap_it).Element.end(), [&lpMem](HEAPCHUNCK &Chunck) { return Chunck.Chunck == lpMem; }); + + if (chunck_it == (*heap_it).Element.end()) + return FALSE; + + int result = munmap((*chunck_it).Chunck, (*chunck_it).dwSize); + + if (result == 0) + { + (*heap_it).Element.erase(chunck_it); + return TRUE; + } + else + return FALSE; + +} + +void OutputDebugString(char* str) +{ + +} + +double GetTickCount(void) +{ +// timespec now; +// clock_gettime() +// if (clock_gettime(CLOCK_MONOTONIC, &now)) +// return 0; + return 10.2;//now.tv_sec * 1000.0 + now.tv_nsec / 1000000.0; +}
\ No newline at end of file diff --git a/ldmicro/lib/linuxUI/linuxLD.h b/ldmicro/lib/linuxUI/linuxLD.h index 0e4f682..e204c63 100644 --- a/ldmicro/lib/linuxUI/linuxLD.h +++ b/ldmicro/lib/linuxUI/linuxLD.h @@ -2,6 +2,10 @@ #define __LINUX_LD__ #include "linuxUI.h" +#include <ctype.h> +#include <vector> +#include <algorithm> +#include <sys/mman.h> /// common windows referances for linux @@ -10,14 +14,21 @@ /// CALLBACK or __stdcall os defined empty #define CALLBACK #define CONST const -/// typedefs + +#define HEAP_ZERO_MEMORY 0x00000008 + +/// Typedefs //typedef int64_t __int64; typedef bool BOOL; typedef unsigned char BYTE; +typedef unsigned short WORD; typedef unsigned int DWORD; +typedef unsigned int UINT; +typedef size_t SIZE_T; typedef long LONG; typedef wchar_t WCHAR; typedef char CHAR; + typedef CONST WCHAR *LPCWSTR; typedef CONST CHAR *LPCSTR; /// should be __nullterminated @@ -36,16 +47,21 @@ typedef CHAR *LPSTR; typedef LPSTR LPTSTR; #endif -/// all handles will hold a GtkWindow* type -typedef void* PVOID; +typedef void *PVOID; +typedef void *LPVOID; +typedef PVOID HFONT; +typedef PVOID HMODULE; +typedef PVOID HHOOK; +typedef PVOID HBRUSH; +typedef PVOID HFONT; typedef PVOID HANDLE; typedef HANDLE HINSTANCE; typedef HANDLE HDC; -typedef GtkWidget* HWID; -typedef GtkWidget* HMENU; -typedef GtkWindow* HWND; -typedef GtkApplication* HAPP; +typedef GtkWidget *HWID; +typedef GtkWidget *HMENU; +typedef GtkWindow *HWND; +typedef GtkApplication *HAPP; /// Check if system is x64 or x86 #if defined(__UNIX64) @@ -55,9 +71,17 @@ typedef unsigned int UINT_PTR; #endif typedef UINT_PTR WPARAM; -typedef unsigned int UINT; -/// custom classes +#if defined(__UNIX64) + typedef __int64_t LONG_PTR; +#else + typedef long LONG_PTR; +#endif + +typedef LONG_PTR LPARAM; +typedef LONG_PTR LRESULT; + +/// Custom classes class COLORREF : public GdkRGBA{ public: COLORREF() @@ -76,6 +100,58 @@ class COLORREF : public GdkRGBA{ } }; -/// functions +/// Custom structures +typedef struct HeapRecordChunckTag{ + PVOID Chunck; + SIZE_T dwSize; +} HEAPCHUNCK; + +typedef struct HeapRecordTag{ + PVOID hHeap; + DWORD HeapID; + std::vector<HEAPCHUNCK> Element; + SIZE_T dwMaximumSize; + SIZE_T dwSize; + SIZE_T dwAllocatedSizeOffset; +} HEAPRECORD; + +typedef struct tagSCROLLINFO { + UINT cbSize; + UINT fMask; + int nMin; + int nMax; + UINT nPage; + int nPos; + int nTrackPos; +} SCROLLINFO, *LPCSCROLLINFO; + +typedef struct tagNMHDR { + HWND hwndFrom; + UINT_PTR idFrom; + UINT code; +} NMHDR; + +/// Variables +extern std::vector<HEAPRECORD> HeapRecord; + +/// Functions +HANDLE HeapCreate( + DWORD flOptions, + SIZE_T dwInitialSize, + SIZE_T dwMaximumSize); + +LPVOID HeapAlloc( + HANDLE hHeap, + DWORD dwFlags, + SIZE_T dwBytes); + +BOOL HeapFree( + HANDLE hHeap, + DWORD dwFlags, + LPVOID lpMem); + +/// functions to be ported +void OutputDebugString(char*); +double GetTickCount(void); #endif
\ No newline at end of file diff --git a/ldmicro/lib/linuxUI/linuxUI.cpp b/ldmicro/lib/linuxUI/linuxUI.cpp index 349408f..3bebf6d 100644 --- a/ldmicro/lib/linuxUI/linuxUI.cpp +++ b/ldmicro/lib/linuxUI/linuxUI.cpp @@ -1,8 +1,5 @@ #include "linuxUI.h" -/// Menu Variables - HWID window; - /// EnableMenuItem Variables const UINT MF_ENABLED = 0; const UINT MF_GRAYED = 1; diff --git a/ldmicro/lib/linuxUI/linuxUI.h b/ldmicro/lib/linuxUI/linuxUI.h index 8efb6ef..c6bb1ac 100644 --- a/ldmicro/lib/linuxUI/linuxUI.h +++ b/ldmicro/lib/linuxUI/linuxUI.h @@ -7,6 +7,7 @@ #include <stdio.h> #include <inttypes.h> #include "linuxLD.h" +//#include "windows.h" /// version control #define LDMicro_VERSION_MAJOR 1 diff --git a/ldmicro/loadsave.cpp b/ldmicro/loadsave.cpp index 2dc4d68..a1895a5 100644 --- a/ldmicro/loadsave.cpp +++ b/ldmicro/loadsave.cpp @@ -20,7 +20,7 @@ // Load/save the circuit from/to a file in a nice ASCII format. // Jonathan Westhues, Nov 2004 //----------------------------------------------------------------------------- -#include <windows.h> +#include "linuxUI.h" #include <stdio.h> #include <stdlib.h> @@ -62,12 +62,10 @@ static BOOL LoadLeafFromFile(char *line, void **any, int *which) } l->d.comment.str[i++] = '\0'; *which = ELEM_COMMENT; - } else if(sscanf(line, "CONTACTS %s %d", l->d.contacts.name, - &l->d.contacts.negated)==2) + } else if(sscanf(line, "CONTACTS %s %d", l->d.contacts.name, &l->d.contacts.negated)==2) { *which = ELEM_CONTACTS; - } else if(sscanf(line, "COIL %s %d %d %d", l->d.coil.name, - &l->d.coil.negated, &l->d.coil.setOnly, &l->d.coil.resetOnly)==4) + } else if(sscanf(line, "COIL %s %d %d %d", l->d.coil.name, &l->d.coil.negated, &l->d.coil.setOnly, &l->d.coil.resetOnly)==4) { *which = ELEM_COIL; } else if(memcmp(line, "PLACEHOLDER", 11)==0) { @@ -78,56 +76,45 @@ static BOOL LoadLeafFromFile(char *line, void **any, int *which) *which = ELEM_OPEN; } else if(memcmp(line, "MASTER_RELAY", 12)==0) { *which = ELEM_MASTER_RELAY; - } else if(sscanf(line, "SHIFT_REGISTER %s %d", l->d.shiftRegister.name, - &(l->d.shiftRegister.stages))==2) + } else if(sscanf(line, "SHIFT_REGISTER %s %d", l->d.shiftRegister.name, &(l->d.shiftRegister.stages))==2) { *which = ELEM_SHIFT_REGISTER; } else if(memcmp(line, "OSR", 3)==0) { *which = ELEM_ONE_SHOT_RISING; } else if(memcmp(line, "OSF", 3)==0) { *which = ELEM_ONE_SHOT_FALLING; - } else if((sscanf(line, "TON %s %d", l->d.timer.name, - &l->d.timer.delay)==2)) + } else if((sscanf(line, "TON %s %d", l->d.timer.name, &l->d.timer.delay)==2)) { *which = ELEM_TON; - } else if((sscanf(line, "TOF %s %d", l->d.timer.name, - &l->d.timer.delay)==2)) + } else if((sscanf(line, "TOF %s %d", l->d.timer.name, &l->d.timer.delay)==2)) { *which = ELEM_TOF; - } else if((sscanf(line, "RTO %s %d", l->d.timer.name, - &l->d.timer.delay)==2)) + } else if((sscanf(line, "RTO %s %d", l->d.timer.name, &l->d.timer.delay)==2)) { *which = ELEM_RTO; - } else if((sscanf(line, "CTD %s %d", l->d.counter.name, - &l->d.counter.max)==2)) + } else if((sscanf(line, "CTD %s %d", l->d.counter.name, &l->d.counter.max)==2)) { *which = ELEM_CTD; - } else if((sscanf(line, "CTU %s %d", l->d.counter.name, - &l->d.counter.max)==2)) + } else if((sscanf(line, "CTU %s %d", l->d.counter.name, &l->d.counter.max)==2)) { *which = ELEM_CTU; - } else if((sscanf(line, "CTC %s %d", l->d.counter.name, - &l->d.counter.max)==2)) + } else if((sscanf(line, "CTC %s %d", l->d.counter.name, &l->d.counter.max)==2)) { *which = ELEM_CTC; } else if(sscanf(line, "RES %s", l->d.reset.name)==1) { *which = ELEM_RES; } else if(sscanf(line, "MOVE %s %s", l->d.move.dest, l->d.move.src)==2) { *which = ELEM_MOVE; - } else if(sscanf(line, "ADD %s %s %s", l->d.math.dest, l->d.math.op1, - l->d.math.op2)==3) + } else if(sscanf(line, "ADD %s %s %s", l->d.math.dest, l->d.math.op1, l->d.math.op2)==3) { *which = ELEM_ADD; - } else if(sscanf(line, "SUB %s %s %s", l->d.math.dest, l->d.math.op1, - l->d.math.op2)==3) + } else if(sscanf(line, "SUB %s %s %s", l->d.math.dest, l->d.math.op1, l->d.math.op2)==3) { *which = ELEM_SUB; - } else if(sscanf(line, "MUL %s %s %s", l->d.math.dest, l->d.math.op1, - l->d.math.op2)==3) + } else if(sscanf(line, "MUL %s %s %s", l->d.math.dest, l->d.math.op1, l->d.math.op2)==3) { *which = ELEM_MUL; - } else if(sscanf(line, "DIV %s %s %s", l->d.math.dest, l->d.math.op1, - l->d.math.op2)==3) + } else if(sscanf(line, "DIV %s %s %s", l->d.math.dest, l->d.math.op1, l->d.math.op2)==3) { *which = ELEM_DIV; } else if(sscanf(line, "EQU %s %s", l->d.cmp.op1, l->d.cmp.op2)==2) { @@ -144,8 +131,7 @@ static BOOL LoadLeafFromFile(char *line, void **any, int *which) *which = ELEM_LES; } else if(sscanf(line, "READ_ADC %s", l->d.readAdc.name)==1) { *which = ELEM_READ_ADC; - } else if(sscanf(line, "SET_PWM %s %d", l->d.setPwm.name, - &(l->d.setPwm.targetFreq))==2) + } else if(sscanf(line, "SET_PWM %s %d", l->d.setPwm.name, &(l->d.setPwm.targetFreq))==2) { *which = ELEM_SET_PWM; } else if(sscanf(line, "UART_RECV %s", l->d.uart.name)==1) { @@ -154,8 +140,7 @@ static BOOL LoadLeafFromFile(char *line, void **any, int *which) *which = ELEM_UART_SEND; } else if(sscanf(line, "PERSIST %s", l->d.persist.var)==1) { *which = ELEM_PERSIST; - } else if(sscanf(line, "FORMATTED_STRING %s %d", l->d.fmtdStr.var, - &x)==2) + } else if(sscanf(line, "FORMATTED_STRING %s %d", l->d.fmtdStr.var, &x)==2) { if(strcmp(l->d.fmtdStr.var, "(none)")==0) { strcpy(l->d.fmtdStr.var, ""); @@ -228,6 +213,7 @@ static BOOL LoadLeafFromFile(char *line, void **any, int *which) return FALSE; } *any = l; + return TRUE; } @@ -283,16 +269,23 @@ static ElemSubcktSeries *LoadSeriesFromFile(FILE *f) int which; ElemSubcktSeries *ret = AllocSubcktSeries(); + int cnt = 0; for(;;) { + if(!fgets(line, sizeof(line), f)) return NULL; + char *s = line; + + while(isspace(*s)) s++; if(strcmp(s, "PARALLEL\n")==0) { + which = ELEM_PARALLEL_SUBCKT; any = LoadParallelFromFile(f); + if(!any) return NULL; } else if(LoadLeafFromFile(s, &any, &which)) { @@ -303,9 +296,11 @@ static ElemSubcktSeries *LoadSeriesFromFile(FILE *f) } else { return NULL; } + ret->contents[cnt].which = which; ret->contents[cnt].d.any = any; cnt++; + if(cnt >= MAX_ELEMENTS_IN_SUBCKT) return NULL; } } @@ -364,10 +359,14 @@ BOOL LoadProjectFromFile(char *filename) int rung; for(rung = 0;;) { if(!fgets(line, sizeof(line), f)) break; + if(strcmp(line, "RUNG\n")!=0) goto failed; Prog.rungs[rung] = LoadSeriesFromFile(f); - if(!Prog.rungs[rung]) goto failed; + + if(!Prog.rungs[rung]) + goto failed; + rung++; } Prog.numRungs = rung; diff --git a/ldmicro/lutdialog.cpp b/ldmicro/lutdialog.cpp index 91898b3..fde3156 100644 --- a/ldmicro/lutdialog.cpp +++ b/ldmicro/lutdialog.cpp @@ -23,29 +23,29 @@ // in between the points. // Jonathan Westhues, Dec 2005 //----------------------------------------------------------------------------- -#include <windows.h> +#include "linuxUI.h" #include <stdio.h> #include <stdlib.h> -#include <commctrl.h> +//#include <commctrl.h> #include "ldmicro.h" -static HWND LutDialog; +// static HWND LutDialog; -static HWND AsStringCheckbox; -static HWND CountTextbox; -static HWND DestTextbox; -static HWND IndexTextbox; -static HWND Labels[3]; +// static HWND AsStringCheckbox; +// static HWND CountTextbox; +// static HWND DestTextbox; +// static HWND IndexTextbox; +// static HWND Labels[3]; -static HWND StringTextbox; +// static HWND StringTextbox; static BOOL WasAsString; static int WasCount; -static HWND ValuesTextbox[MAX_LOOK_UP_TABLE_LEN]; +//static HWND ValuesTextbox[MAX_LOOK_UP_TABLE_LEN]; static LONG_PTR PrevValuesProc[MAX_LOOK_UP_TABLE_LEN]; -static HWND ValuesLabel[MAX_LOOK_UP_TABLE_LEN]; +//static HWND ValuesLabel[MAX_LOOK_UP_TABLE_LEN]; static SWORD ValuesCache[MAX_LOOK_UP_TABLE_LEN]; @@ -56,65 +56,65 @@ static LONG_PTR PrevCountProc; //----------------------------------------------------------------------------- // Don't allow any characters other than 0-9 and minus in the values. //----------------------------------------------------------------------------- -static LRESULT CALLBACK MyNumberProc(HWND hwnd, UINT msg, WPARAM wParam, - LPARAM lParam) -{ - if(msg == WM_CHAR) { - if(!(isdigit(wParam) || wParam == '\b' || wParam == '-')) { - return 0; - } - } +// static LRESULT CALLBACK MyNumberProc(HWND hwnd, UINT msg, WPARAM wParam, +// LPARAM lParam) +// { +// if(msg == WM_CHAR) { +// if(!(isdigit(wParam) || wParam == '\b' || wParam == '-')) { +// return 0; +// } +// } - WNDPROC w; - int i; - for(i = 0; i < MAX_LOOK_UP_TABLE_LEN; i++) { - if(hwnd == ValuesTextbox[i]) { - w = (WNDPROC)PrevValuesProc[i]; - break; - } - } - if(i == MAX_LOOK_UP_TABLE_LEN) oops(); - - return CallWindowProc(w, hwnd, msg, wParam, lParam); -} +// WNDPROC w; +// int i; +// for(i = 0; i < MAX_LOOK_UP_TABLE_LEN; i++) { +// if(hwnd == ValuesTextbox[i]) { +// w = (WNDPROC)PrevValuesProc[i]; +// break; +// } +// } +// if(i == MAX_LOOK_UP_TABLE_LEN) oops(); + +// return CallWindowProc(w, hwnd, msg, wParam, lParam); +// } //----------------------------------------------------------------------------- // Don't allow any characters other than 0-9 in the count. //----------------------------------------------------------------------------- -static LRESULT CALLBACK MyDigitsProc(HWND hwnd, UINT msg, WPARAM wParam, - LPARAM lParam) -{ - if(msg == WM_CHAR) { - if(!(isdigit(wParam) || wParam == '\b')) { - return 0; - } - } - - return CallWindowProc((WNDPROC)PrevCountProc, hwnd, msg, wParam, lParam); -} +// static LRESULT CALLBACK MyDigitsProc(HWND hwnd, UINT msg, WPARAM wParam, +// LPARAM lParam) +// { +// if(msg == WM_CHAR) { +// if(!(isdigit(wParam) || wParam == '\b')) { +// return 0; +// } +// } + +// return CallWindowProc((WNDPROC)PrevCountProc, hwnd, msg, wParam, lParam); +// } //----------------------------------------------------------------------------- // Don't allow any characters other than A-Za-z0-9_ in the name. //----------------------------------------------------------------------------- -static LRESULT CALLBACK MyNameProc(HWND hwnd, UINT msg, WPARAM wParam, - LPARAM lParam) -{ - if(msg == WM_CHAR) { - if(!(isalpha(wParam) || isdigit(wParam) || wParam == '_' || - wParam == '\b')) - { - return 0; - } - } - - WNDPROC w; - if(hwnd == DestTextbox) { - w = (WNDPROC)PrevDestProc; - } else if(hwnd == IndexTextbox) { - w = (WNDPROC)PrevIndexProc; - } - return CallWindowProc(w, hwnd, msg, wParam, lParam); -} +// static LRESULT CALLBACK MyNameProc(HWND hwnd, UINT msg, WPARAM wParam, +// LPARAM lParam) +// { +// if(msg == WM_CHAR) { +// if(!(isalpha(wParam) || isdigit(wParam) || wParam == '_' || +// wParam == '\b')) +// { +// return 0; +// } +// } + +// WNDPROC w; +// if(hwnd == DestTextbox) { +// w = (WNDPROC)PrevDestProc; +// } else if(hwnd == IndexTextbox) { +// w = (WNDPROC)PrevIndexProc; +// } +// return CallWindowProc(w, hwnd, msg, wParam, lParam); +// } //----------------------------------------------------------------------------- // Make the controls that are guaranteed not to move around as the count/ @@ -122,92 +122,92 @@ static LRESULT CALLBACK MyNameProc(HWND hwnd, UINT msg, WPARAM wParam, // because in that case we should not provide a checkbox to change whether // the table is edited as a string or table. //----------------------------------------------------------------------------- -static void MakeFixedControls(BOOL forPwl) -{ - Labels[0] = CreateWindowEx(0, WC_STATIC, _("Destination:"), - WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SS_RIGHT, - 0, 10, 78, 21, LutDialog, NULL, Instance, NULL); - NiceFont(Labels[0]); - - DestTextbox = CreateWindowEx(WS_EX_CLIENTEDGE, WC_EDIT, "", - WS_CHILD | ES_AUTOHSCROLL | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE, - 85, 10, 120, 21, LutDialog, NULL, Instance, NULL); - FixedFont(DestTextbox); - - Labels[1] = CreateWindowEx(0, WC_STATIC, _("Index:"), - WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SS_RIGHT, - 10, 40, 68, 21, LutDialog, NULL, Instance, NULL); - NiceFont(Labels[1]); - - IndexTextbox = CreateWindowEx(WS_EX_CLIENTEDGE, WC_EDIT, "", - WS_CHILD | ES_AUTOHSCROLL | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE, - 85, 40, 120, 21, LutDialog, NULL, Instance, NULL); - FixedFont(IndexTextbox); - - Labels[2] = CreateWindowEx(0,WC_STATIC, forPwl ? _("Points:") : _("Count:"), - WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SS_RIGHT, - 0, 70, 78, 21, LutDialog, NULL, Instance, NULL); - NiceFont(Labels[2]); - - CountTextbox = CreateWindowEx(WS_EX_CLIENTEDGE, WC_EDIT, "", - WS_CHILD | ES_AUTOHSCROLL | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE, - 85, 70, 120, 21, LutDialog, NULL, Instance, NULL); - NiceFont(CountTextbox); - - if(!forPwl) { - AsStringCheckbox = CreateWindowEx(0, WC_BUTTON, - _("Edit table of ASCII values like a string"), WS_CHILD | - WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE | BS_AUTOCHECKBOX, - 10, 100, 300, 21, LutDialog, NULL, Instance, NULL); - NiceFont(AsStringCheckbox); - } - - OkButton = CreateWindowEx(0, WC_BUTTON, _("OK"), - WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE | BS_DEFPUSHBUTTON, - 231, 10, 70, 23, LutDialog, NULL, Instance, NULL); - NiceFont(OkButton); - - CancelButton = CreateWindowEx(0, WC_BUTTON, _("Cancel"), - WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE, - 231, 40, 70, 23, LutDialog, NULL, Instance, NULL); - NiceFont(CancelButton); - - PrevDestProc = SetWindowLongPtr(DestTextbox, GWLP_WNDPROC, - (LONG_PTR)MyNameProc); - PrevIndexProc = SetWindowLongPtr(IndexTextbox, GWLP_WNDPROC, - (LONG_PTR)MyNameProc); - PrevCountProc = SetWindowLongPtr(CountTextbox, GWLP_WNDPROC, - (LONG_PTR)MyDigitsProc); -} +// static void MakeFixedControls(BOOL forPwl) +// { +// Labels[0] = CreateWindowEx(0, WC_STATIC, _("Destination:"), +// WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SS_RIGHT, +// 0, 10, 78, 21, LutDialog, NULL, Instance, NULL); +// NiceFont(Labels[0]); + +// DestTextbox = CreateWindowEx(WS_EX_CLIENTEDGE, WC_EDIT, "", +// WS_CHILD | ES_AUTOHSCROLL | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE, +// 85, 10, 120, 21, LutDialog, NULL, Instance, NULL); +// FixedFont(DestTextbox); + +// Labels[1] = CreateWindowEx(0, WC_STATIC, _("Index:"), +// WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SS_RIGHT, +// 10, 40, 68, 21, LutDialog, NULL, Instance, NULL); +// NiceFont(Labels[1]); + +// IndexTextbox = CreateWindowEx(WS_EX_CLIENTEDGE, WC_EDIT, "", +// WS_CHILD | ES_AUTOHSCROLL | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE, +// 85, 40, 120, 21, LutDialog, NULL, Instance, NULL); +// FixedFont(IndexTextbox); + +// Labels[2] = CreateWindowEx(0,WC_STATIC, forPwl ? _("Points:") : _("Count:"), +// WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SS_RIGHT, +// 0, 70, 78, 21, LutDialog, NULL, Instance, NULL); +// NiceFont(Labels[2]); + +// CountTextbox = CreateWindowEx(WS_EX_CLIENTEDGE, WC_EDIT, "", +// WS_CHILD | ES_AUTOHSCROLL | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE, +// 85, 70, 120, 21, LutDialog, NULL, Instance, NULL); +// NiceFont(CountTextbox); + +// if(!forPwl) { +// AsStringCheckbox = CreateWindowEx(0, WC_BUTTON, +// _("Edit table of ASCII values like a string"), WS_CHILD | +// WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE | BS_AUTOCHECKBOX, +// 10, 100, 300, 21, LutDialog, NULL, Instance, NULL); +// NiceFont(AsStringCheckbox); +// } + +// OkButton = CreateWindowEx(0, WC_BUTTON, _("OK"), +// WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE | BS_DEFPUSHBUTTON, +// 231, 10, 70, 23, LutDialog, NULL, Instance, NULL); +// NiceFont(OkButton); + +// CancelButton = CreateWindowEx(0, WC_BUTTON, _("Cancel"), +// WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE, +// 231, 40, 70, 23, LutDialog, NULL, Instance, NULL); +// NiceFont(CancelButton); + +// PrevDestProc = SetWindowLongPtr(DestTextbox, GWLP_WNDPROC, +// (LONG_PTR)MyNameProc); +// PrevIndexProc = SetWindowLongPtr(IndexTextbox, GWLP_WNDPROC, +// (LONG_PTR)MyNameProc); +// PrevCountProc = SetWindowLongPtr(CountTextbox, GWLP_WNDPROC, +// (LONG_PTR)MyDigitsProc); +// } //----------------------------------------------------------------------------- // Destroy all of the controls so that we can start anew. This is necessary // because if the size of the LUT changes, or if the user switches from // table entry to string entry, we must completely reconfigure the dialog. //----------------------------------------------------------------------------- -static void DestroyLutControls(void) -{ - if(WasAsString) { - // Nothing to do; we constantly update the cache from the user- - // specified string, because we might as well do that when we - // calculate the length. - } else { - int i; - for(i = 0; i < WasCount; i++) { - char buf[20]; - SendMessage(ValuesTextbox[i], WM_GETTEXT, (WPARAM)16, (LPARAM)buf); - ValuesCache[i] = atoi(buf); - } - } - - DestroyWindow(StringTextbox); - - int i; - for(i = 0; i < MAX_LOOK_UP_TABLE_LEN; i++) { - DestroyWindow(ValuesTextbox[i]); - DestroyWindow(ValuesLabel[i]); - } -} +// static void DestroyLutControls(void) +// { +// if(WasAsString) { +// // Nothing to do; we constantly update the cache from the user- +// // specified string, because we might as well do that when we +// // calculate the length. +// } else { +// int i; +// for(i = 0; i < WasCount; i++) { +// char buf[20]; +// SendMessage(ValuesTextbox[i], WM_GETTEXT, (WPARAM)16, (LPARAM)buf); +// ValuesCache[i] = atoi(buf); +// } +// } + +// DestroyWindow(StringTextbox); + +// int i; +// for(i = 0; i < MAX_LOOK_UP_TABLE_LEN; i++) { +// DestroyWindow(ValuesTextbox[i]); +// DestroyWindow(ValuesLabel[i]); +// } +// } //----------------------------------------------------------------------------- // Make the controls that hold the LUT. The exact configuration of the dialog @@ -215,96 +215,96 @@ static void DestroyLutControls(void) // and for table-type entry, on (b) the number of entries, and on (c) // whether we are editing a PWL table (list of points) or a straight LUT. //----------------------------------------------------------------------------- -static void MakeLutControls(BOOL asString, int count, BOOL forPwl) -{ - // Remember these, so that we know from where to cache stuff if we have - // to destroy these textboxes and make something new later. - WasAsString = asString; - WasCount = count; - - if(forPwl && asString) oops(); - - if(asString) { - char str[3*MAX_LOOK_UP_TABLE_LEN+1]; - int i, j; - j = 0; - for(i = 0; i < count; i++) { - int c = ValuesCache[i]; - if(c >= 32 && c <= 127 && c != '\\') { - str[j++] = c; - } else if(c == '\\') { - str[j++] = '\\'; - str[j++] = '\\'; - } else if(c == '\r') { - str[j++] = '\\'; - str[j++] = 'r'; - } else if(c == '\b') { - str[j++] = '\\'; - str[j++] = 'b'; - } else if(c == '\f') { - str[j++] = '\\'; - str[j++] = 'f'; - } else if(c == '\n') { - str[j++] = '\\'; - str[j++] = 'n'; - } else { - str[j++] = 'X'; - } - } - str[j++] = '\0'; - StringTextbox = CreateWindowEx(WS_EX_CLIENTEDGE, WC_EDIT, str, - WS_CHILD | ES_AUTOHSCROLL | WS_TABSTOP | WS_CLIPSIBLINGS | - WS_VISIBLE, - 10, 130, 294, 21, LutDialog, NULL, Instance, NULL); - FixedFont(StringTextbox); - SendMessage(CountTextbox, EM_SETREADONLY, (WPARAM)TRUE, 0); - MoveWindow(LutDialog, 100, 30, 320, 185, TRUE); - } else { - int i; - int base; - if(forPwl) { - base = 100; - } else { - base = 140; - } - for(i = 0; i < count; i++) { - int x, y; - - if(i < 16) { - x = 10; - y = base+30*i; - } else { - x = 160; - y = base+30*(i-16); - } - - char buf[20]; - sprintf(buf, "%d", ValuesCache[i]); - ValuesTextbox[i] = CreateWindowEx(WS_EX_CLIENTEDGE, WC_EDIT, buf, - WS_CHILD | ES_AUTOHSCROLL | WS_TABSTOP | WS_CLIPSIBLINGS | - WS_VISIBLE, - x+30, y, 80, 21, LutDialog, NULL, Instance, NULL); - NiceFont(ValuesTextbox[i]); - - if(forPwl) { - sprintf(buf, "%c%d:", (i & 1) ? 'y' : 'x', i/2); - } else { - sprintf(buf, "%2d:", i); - } - ValuesLabel[i] = CreateWindowEx(0, WC_STATIC, buf, - WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE, - x, y+3, 100, 21, LutDialog, NULL, Instance, NULL); - FixedFont(ValuesLabel[i]); - - PrevValuesProc[i] = SetWindowLongPtr(ValuesTextbox[i], - GWLP_WNDPROC, (LONG_PTR)MyNumberProc); - } - if(count > 16) count = 16; - SendMessage(CountTextbox, EM_SETREADONLY, (WPARAM)FALSE, 0); - - MoveWindow(LutDialog, 100, 30, 320, base + 30 + count*30, TRUE); - } -} +// static void MakeLutControls(BOOL asString, int count, BOOL forPwl) +// { +// // Remember these, so that we know from where to cache stuff if we have +// // to destroy these textboxes and make something new later. +// WasAsString = asString; +// WasCount = count; + +// if(forPwl && asString) oops(); + +// if(asString) { +// char str[3*MAX_LOOK_UP_TABLE_LEN+1]; +// int i, j; +// j = 0; +// for(i = 0; i < count; i++) { +// int c = ValuesCache[i]; +// if(c >= 32 && c <= 127 && c != '\\') { +// str[j++] = c; +// } else if(c == '\\') { +// str[j++] = '\\'; +// str[j++] = '\\'; +// } else if(c == '\r') { +// str[j++] = '\\'; +// str[j++] = 'r'; +// } else if(c == '\b') { +// str[j++] = '\\'; +// str[j++] = 'b'; +// } else if(c == '\f') { +// str[j++] = '\\'; +// str[j++] = 'f'; +// } else if(c == '\n') { +// str[j++] = '\\'; +// str[j++] = 'n'; +// } else { +// str[j++] = 'X'; +// } +// } +// str[j++] = '\0'; +// StringTextbox = CreateWindowEx(WS_EX_CLIENTEDGE, WC_EDIT, str, +// WS_CHILD | ES_AUTOHSCROLL | WS_TABSTOP | WS_CLIPSIBLINGS | +// WS_VISIBLE, +// 10, 130, 294, 21, LutDialog, NULL, Instance, NULL); +// FixedFont(StringTextbox); +// SendMessage(CountTextbox, EM_SETREADONLY, (WPARAM)TRUE, 0); +// MoveWindow(LutDialog, 100, 30, 320, 185, TRUE); +// } else { +// int i; +// int base; +// if(forPwl) { +// base = 100; +// } else { +// base = 140; +// } +// for(i = 0; i < count; i++) { +// int x, y; + +// if(i < 16) { +// x = 10; +// y = base+30*i; +// } else { +// x = 160; +// y = base+30*(i-16); +// } + +// char buf[20]; +// sprintf(buf, "%d", ValuesCache[i]); +// ValuesTextbox[i] = CreateWindowEx(WS_EX_CLIENTEDGE, WC_EDIT, buf, +// WS_CHILD | ES_AUTOHSCROLL | WS_TABSTOP | WS_CLIPSIBLINGS | +// WS_VISIBLE, +// x+30, y, 80, 21, LutDialog, NULL, Instance, NULL); +// NiceFont(ValuesTextbox[i]); + +// if(forPwl) { +// sprintf(buf, "%c%d:", (i & 1) ? 'y' : 'x', i/2); +// } else { +// sprintf(buf, "%2d:", i); +// } +// ValuesLabel[i] = CreateWindowEx(0, WC_STATIC, buf, +// WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE, +// x, y+3, 100, 21, LutDialog, NULL, Instance, NULL); +// FixedFont(ValuesLabel[i]); + +// PrevValuesProc[i] = SetWindowLongPtr(ValuesTextbox[i], +// GWLP_WNDPROC, (LONG_PTR)MyNumberProc); +// } +// if(count > 16) count = 16; +// SendMessage(CountTextbox, EM_SETREADONLY, (WPARAM)FALSE, 0); + +// MoveWindow(LutDialog, 100, 30, 320, base + 30 + count*30, TRUE); +// } +// } //----------------------------------------------------------------------------- // Decode a string into a look-up table; store the values in ValuesCache[], @@ -312,36 +312,36 @@ static void MakeLutControls(BOOL asString, int count, BOOL forPwl) // reflect the new length. Returns FALSE if the new string is too long, else // TRUE. //----------------------------------------------------------------------------- -BOOL StringToValuesCache(char *str, int *c) -{ - int count = 0; - while(*str) { - if(*str == '\\') { - str++; - switch(*str) { - case 'r': ValuesCache[count++] = '\r'; break; - case 'n': ValuesCache[count++] = '\n'; break; - case 'f': ValuesCache[count++] = '\f'; break; - case 'b': ValuesCache[count++] = '\b'; break; - default: ValuesCache[count++] = *str; break; - } - } else { - ValuesCache[count++] = *str; - } - if(*str) { - str++; - } - if(count >= 32) { - return FALSE; - } - } - - char buf[10]; - sprintf(buf, "%d", count); - SendMessage(CountTextbox, WM_SETTEXT, 0, (LPARAM)(buf)); - *c = count; - return TRUE; -} +// BOOL StringToValuesCache(char *str, int *c) +// { +// int count = 0; +// while(*str) { +// if(*str == '\\') { +// str++; +// switch(*str) { +// case 'r': ValuesCache[count++] = '\r'; break; +// case 'n': ValuesCache[count++] = '\n'; break; +// case 'f': ValuesCache[count++] = '\f'; break; +// case 'b': ValuesCache[count++] = '\b'; break; +// default: ValuesCache[count++] = *str; break; +// } +// } else { +// ValuesCache[count++] = *str; +// } +// if(*str) { +// str++; +// } +// if(count >= 32) { +// return FALSE; +// } +// } + +// char buf[10]; +// sprintf(buf, "%d", count); +// SendMessage(CountTextbox, WM_SETTEXT, 0, (LPARAM)(buf)); +// *c = count; +// return TRUE; +// } //----------------------------------------------------------------------------- // Show the look-up table dialog. This one is nasty, mostly because there are @@ -349,217 +349,217 @@ BOOL StringToValuesCache(char *str, int *c) // I should convert between those two representations on the fly, as the user // edit things, so I do. //----------------------------------------------------------------------------- -void ShowLookUpTableDialog(ElemLeaf *l) -{ - ElemLookUpTable *t = &(l->d.lookUpTable); - - // First copy over all the stuff from the leaf structure; in particular, - // we need our own local copy of the table entries, because it would be - // bad to update those in the leaf before the user clicks okay (as he - // might cancel). - int count = t->count; - BOOL asString = t->editAsString; - memset(ValuesCache, 0, sizeof(ValuesCache)); - int i; - for(i = 0; i < count; i++) { - ValuesCache[i] = t->vals[i]; - } - - // Now create the dialog's fixed controls, plus the changing (depending - // on show style/entry count) controls for the initial configuration. - LutDialog = CreateWindowClient(0, "LDmicroDialog", - _("Look-Up Table"), WS_OVERLAPPED | WS_SYSMENU, - 100, 100, 320, 375, NULL, NULL, Instance, NULL); - MakeFixedControls(FALSE); - MakeLutControls(asString, count, FALSE); +// void ShowLookUpTableDialog(ElemLeaf *l) +// { +// ElemLookUpTable *t = &(l->d.lookUpTable); + +// // First copy over all the stuff from the leaf structure; in particular, +// // we need our own local copy of the table entries, because it would be +// // bad to update those in the leaf before the user clicks okay (as he +// // might cancel). +// int count = t->count; +// BOOL asString = t->editAsString; +// memset(ValuesCache, 0, sizeof(ValuesCache)); +// int i; +// for(i = 0; i < count; i++) { +// ValuesCache[i] = t->vals[i]; +// } + +// // Now create the dialog's fixed controls, plus the changing (depending +// // on show style/entry count) controls for the initial configuration. +// LutDialog = CreateWindowClient(0, "LDmicroDialog", +// _("Look-Up Table"), WS_OVERLAPPED | WS_SYSMENU, +// 100, 100, 320, 375, NULL, NULL, Instance, NULL); +// MakeFixedControls(FALSE); +// MakeLutControls(asString, count, FALSE); - // Set up the controls to reflect the initial configuration. - SendMessage(DestTextbox, WM_SETTEXT, 0, (LPARAM)(t->dest)); - SendMessage(IndexTextbox, WM_SETTEXT, 0, (LPARAM)(t->index)); - char buf[30]; - sprintf(buf, "%d", t->count); - SendMessage(CountTextbox, WM_SETTEXT, 0, (LPARAM)buf); - if(asString) { - SendMessage(AsStringCheckbox, BM_SETCHECK, BST_CHECKED, 0); - } - - // And show the window - EnableWindow(MainWindow, FALSE); - ShowWindow(LutDialog, TRUE); - SetFocus(DestTextbox); - SendMessage(DestTextbox, EM_SETSEL, 0, -1); - - char PrevTableAsString[1024] = ""; - - MSG msg; - DWORD ret; - DialogDone = FALSE; - DialogCancel = FALSE; - while((ret = GetMessage(&msg, NULL, 0, 0)) && !DialogDone) { - if(msg.message == WM_KEYDOWN) { - if(msg.wParam == VK_RETURN) { - DialogDone = TRUE; - break; - } else if(msg.wParam == VK_ESCAPE) { - DialogDone = TRUE; - DialogCancel = TRUE; - break; - } - } - - if(!IsDialogMessage(LutDialog, &msg)) { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - - // Are we in table mode? In that case watch the (user-editable) count - // field, and use that to determine how many textboxes to show. - char buf[20]; - SendMessage(CountTextbox, WM_GETTEXT, (WPARAM)16, (LPARAM)buf); - if(atoi(buf) != count && !asString) { - count = atoi(buf); - if(count < 0 || count > 32) { - count = 0; - SendMessage(CountTextbox, WM_SETTEXT, 0, (LPARAM)""); - } - DestroyLutControls(); - MakeLutControls(asString, count, FALSE); - } - - // Are we in string mode? In that case watch the string textbox, - // and use that to update the (read-only) count field. - if(asString) { - char scratch[1024]; - SendMessage(StringTextbox, WM_GETTEXT, (WPARAM)sizeof(scratch), - (LPARAM)scratch); - if(strcmp(scratch, PrevTableAsString)!=0) { - if(StringToValuesCache(scratch, &count)) { - strcpy(PrevTableAsString, scratch); - } else { - // Too long; put back the old one - SendMessage(StringTextbox, WM_SETTEXT, 0, - (LPARAM)PrevTableAsString); - } - } - } - - // Did we just change modes? - BOOL x = SendMessage(AsStringCheckbox, BM_GETCHECK, 0, 0)==BST_CHECKED; - if((x && !asString) || (!x && asString)) { - asString = x; - DestroyLutControls(); - MakeLutControls(asString, count, FALSE); - } - - } - - if(!DialogCancel) { - SendMessage(DestTextbox, WM_GETTEXT, (WPARAM)16, (LPARAM)(t->dest)); - SendMessage(IndexTextbox, WM_GETTEXT, (WPARAM)16, (LPARAM)(t->index)); - DestroyLutControls(); - // The call to DestroyLutControls updated ValuesCache, so just read - // them out of there (whichever mode we were in before). - int i; - for(i = 0; i < count; i++) { - t->vals[i] = ValuesCache[i]; - } - t->count = count; - t->editAsString = asString; - } - - EnableWindow(MainWindow, TRUE); - DestroyWindow(LutDialog); -} +// // Set up the controls to reflect the initial configuration. +// SendMessage(DestTextbox, WM_SETTEXT, 0, (LPARAM)(t->dest)); +// SendMessage(IndexTextbox, WM_SETTEXT, 0, (LPARAM)(t->index)); +// char buf[30]; +// sprintf(buf, "%d", t->count); +// SendMessage(CountTextbox, WM_SETTEXT, 0, (LPARAM)buf); +// if(asString) { +// SendMessage(AsStringCheckbox, BM_SETCHECK, BST_CHECKED, 0); +// } + +// // And show the window +// EnableWindow(MainWindow, FALSE); +// ShowWindow(LutDialog, TRUE); +// SetFocus(DestTextbox); +// SendMessage(DestTextbox, EM_SETSEL, 0, -1); + +// char PrevTableAsString[1024] = ""; + +// MSG msg; +// DWORD ret; +// DialogDone = FALSE; +// DialogCancel = FALSE; +// while((ret = GetMessage(&msg, NULL, 0, 0)) && !DialogDone) { +// if(msg.message == WM_KEYDOWN) { +// if(msg.wParam == VK_RETURN) { +// DialogDone = TRUE; +// break; +// } else if(msg.wParam == VK_ESCAPE) { +// DialogDone = TRUE; +// DialogCancel = TRUE; +// break; +// } +// } + +// if(!IsDialogMessage(LutDialog, &msg)) { +// TranslateMessage(&msg); +// DispatchMessage(&msg); +// } + +// // Are we in table mode? In that case watch the (user-editable) count +// // field, and use that to determine how many textboxes to show. +// char buf[20]; +// SendMessage(CountTextbox, WM_GETTEXT, (WPARAM)16, (LPARAM)buf); +// if(atoi(buf) != count && !asString) { +// count = atoi(buf); +// if(count < 0 || count > 32) { +// count = 0; +// SendMessage(CountTextbox, WM_SETTEXT, 0, (LPARAM)""); +// } +// DestroyLutControls(); +// MakeLutControls(asString, count, FALSE); +// } + +// // Are we in string mode? In that case watch the string textbox, +// // and use that to update the (read-only) count field. +// if(asString) { +// char scratch[1024]; +// SendMessage(StringTextbox, WM_GETTEXT, (WPARAM)sizeof(scratch), +// (LPARAM)scratch); +// if(strcmp(scratch, PrevTableAsString)!=0) { +// if(StringToValuesCache(scratch, &count)) { +// strcpy(PrevTableAsString, scratch); +// } else { +// // Too long; put back the old one +// SendMessage(StringTextbox, WM_SETTEXT, 0, +// (LPARAM)PrevTableAsString); +// } +// } +// } + +// // Did we just change modes? +// BOOL x = SendMessage(AsStringCheckbox, BM_GETCHECK, 0, 0)==BST_CHECKED; +// if((x && !asString) || (!x && asString)) { +// asString = x; +// DestroyLutControls(); +// MakeLutControls(asString, count, FALSE); +// } + +// } + +// if(!DialogCancel) { +// SendMessage(DestTextbox, WM_GETTEXT, (WPARAM)16, (LPARAM)(t->dest)); +// SendMessage(IndexTextbox, WM_GETTEXT, (WPARAM)16, (LPARAM)(t->index)); +// DestroyLutControls(); +// // The call to DestroyLutControls updated ValuesCache, so just read +// // them out of there (whichever mode we were in before). +// int i; +// for(i = 0; i < count; i++) { +// t->vals[i] = ValuesCache[i]; +// } +// t->count = count; +// t->editAsString = asString; +// } + +// EnableWindow(MainWindow, TRUE); +// DestroyWindow(LutDialog); +// } //----------------------------------------------------------------------------- // Show the piecewise linear table dialog. This one can only be edited in // only a single format, which makes things easier than before. //----------------------------------------------------------------------------- -void ShowPiecewiseLinearDialog(ElemLeaf *l) -{ - ElemPiecewiseLinear *t = &(l->d.piecewiseLinear); - - // First copy over all the stuff from the leaf structure; in particular, - // we need our own local copy of the table entries, because it would be - // bad to update those in the leaf before the user clicks okay (as he - // might cancel). - int count = t->count; - memset(ValuesCache, 0, sizeof(ValuesCache)); - int i; - for(i = 0; i < count*2; i++) { - ValuesCache[i] = t->vals[i]; - } - - // Now create the dialog's fixed controls, plus the changing (depending - // on show style/entry count) controls for the initial configuration. - LutDialog = CreateWindowClient(0, "LDmicroDialog", - _("Piecewise Linear Table"), WS_OVERLAPPED | WS_SYSMENU, - 100, 100, 320, 375, NULL, NULL, Instance, NULL); - MakeFixedControls(TRUE); - MakeLutControls(FALSE, count*2, TRUE); +// void ShowPiecewiseLinearDialog(ElemLeaf *l) +// { +// ElemPiecewiseLinear *t = &(l->d.piecewiseLinear); + +// // First copy over all the stuff from the leaf structure; in particular, +// // we need our own local copy of the table entries, because it would be +// // bad to update those in the leaf before the user clicks okay (as he +// // might cancel). +// int count = t->count; +// memset(ValuesCache, 0, sizeof(ValuesCache)); +// int i; +// for(i = 0; i < count*2; i++) { +// ValuesCache[i] = t->vals[i]; +// } + +// // Now create the dialog's fixed controls, plus the changing (depending +// // on show style/entry count) controls for the initial configuration. +// LutDialog = CreateWindowClient(0, "LDmicroDialog", +// _("Piecewise Linear Table"), WS_OVERLAPPED | WS_SYSMENU, +// 100, 100, 320, 375, NULL, NULL, Instance, NULL); +// MakeFixedControls(TRUE); +// MakeLutControls(FALSE, count*2, TRUE); - // Set up the controls to reflect the initial configuration. - SendMessage(DestTextbox, WM_SETTEXT, 0, (LPARAM)(t->dest)); - SendMessage(IndexTextbox, WM_SETTEXT, 0, (LPARAM)(t->index)); - char buf[30]; - sprintf(buf, "%d", t->count); - SendMessage(CountTextbox, WM_SETTEXT, 0, (LPARAM)buf); - - // And show the window - EnableWindow(MainWindow, FALSE); - ShowWindow(LutDialog, TRUE); - SetFocus(DestTextbox); - SendMessage(DestTextbox, EM_SETSEL, 0, -1); - - MSG msg; - DWORD ret; - DialogDone = FALSE; - DialogCancel = FALSE; - while((ret = GetMessage(&msg, NULL, 0, 0)) && !DialogDone) { - if(msg.message == WM_KEYDOWN) { - if(msg.wParam == VK_RETURN) { - DialogDone = TRUE; - break; - } else if(msg.wParam == VK_ESCAPE) { - DialogDone = TRUE; - DialogCancel = TRUE; - break; - } - } - - if(!IsDialogMessage(LutDialog, &msg)) { - TranslateMessage(&msg); - DispatchMessage(&msg); - } - - // Watch the (user-editable) count field, and use that to - // determine how many textboxes to show. - char buf[20]; - SendMessage(CountTextbox, WM_GETTEXT, (WPARAM)16, (LPARAM)buf); - if(atoi(buf) != count) { - count = atoi(buf); - if(count < 0 || count > 10) { - count = 0; - SendMessage(CountTextbox, WM_SETTEXT, 0, (LPARAM)""); - } - DestroyLutControls(); - MakeLutControls(FALSE, count*2, TRUE); - } - } - - if(!DialogCancel) { - SendMessage(DestTextbox, WM_GETTEXT, (WPARAM)16, (LPARAM)(t->dest)); - SendMessage(IndexTextbox, WM_GETTEXT, (WPARAM)16, (LPARAM)(t->index)); - DestroyLutControls(); - // The call to DestroyLutControls updated ValuesCache, so just read - // them out of there. - int i; - for(i = 0; i < count*2; i++) { - t->vals[i] = ValuesCache[i]; - } - t->count = count; - } - - EnableWindow(MainWindow, TRUE); - DestroyWindow(LutDialog); -} +// // Set up the controls to reflect the initial configuration. +// SendMessage(DestTextbox, WM_SETTEXT, 0, (LPARAM)(t->dest)); +// SendMessage(IndexTextbox, WM_SETTEXT, 0, (LPARAM)(t->index)); +// char buf[30]; +// sprintf(buf, "%d", t->count); +// SendMessage(CountTextbox, WM_SETTEXT, 0, (LPARAM)buf); + +// // And show the window +// EnableWindow(MainWindow, FALSE); +// ShowWindow(LutDialog, TRUE); +// SetFocus(DestTextbox); +// SendMessage(DestTextbox, EM_SETSEL, 0, -1); + +// MSG msg; +// DWORD ret; +// DialogDone = FALSE; +// DialogCancel = FALSE; +// while((ret = GetMessage(&msg, NULL, 0, 0)) && !DialogDone) { +// if(msg.message == WM_KEYDOWN) { +// if(msg.wParam == VK_RETURN) { +// DialogDone = TRUE; +// break; +// } else if(msg.wParam == VK_ESCAPE) { +// DialogDone = TRUE; +// DialogCancel = TRUE; +// break; +// } +// } + +// if(!IsDialogMessage(LutDialog, &msg)) { +// TranslateMessage(&msg); +// DispatchMessage(&msg); +// } + +// // Watch the (user-editable) count field, and use that to +// // determine how many textboxes to show. +// char buf[20]; +// SendMessage(CountTextbox, WM_GETTEXT, (WPARAM)16, (LPARAM)buf); +// if(atoi(buf) != count) { +// count = atoi(buf); +// if(count < 0 || count > 10) { +// count = 0; +// SendMessage(CountTextbox, WM_SETTEXT, 0, (LPARAM)""); +// } +// DestroyLutControls(); +// MakeLutControls(FALSE, count*2, TRUE); +// } +// } + +// if(!DialogCancel) { +// SendMessage(DestTextbox, WM_GETTEXT, (WPARAM)16, (LPARAM)(t->dest)); +// SendMessage(IndexTextbox, WM_GETTEXT, (WPARAM)16, (LPARAM)(t->index)); +// DestroyLutControls(); +// // The call to DestroyLutControls updated ValuesCache, so just read +// // them out of there. +// int i; +// for(i = 0; i < count*2; i++) { +// t->vals[i] = ValuesCache[i]; +// } +// t->count = count; +// } + +// EnableWindow(MainWindow, TRUE); +// DestroyWindow(LutDialog); +// } diff --git a/ldmicro/maincontrols.cpp b/ldmicro/maincontrols.cpp index 38c9b9f..06143ad 100644 --- a/ldmicro/maincontrols.cpp +++ b/ldmicro/maincontrols.cpp @@ -22,15 +22,15 @@ // scrolling, I/O list, menus. // Jonathan Westhues, Nov 2004 //----------------------------------------------------------------------------- -#include <windows.h> -#include <commctrl.h> -#include <commdlg.h> +#include "linuxUI.h" +//#include <commctrl.h> +//#include <commdlg.h> #include <stdio.h> #include <stdlib.h> #include "ldmicro.h" // Menu IDs - HMENU MNU_NEW; +HMENU MNU_NEW; HMENU MNU_OPEN; HMENU MNU_SAVE; HMENU MNU_SAVE_AS; @@ -100,29 +100,27 @@ HMENU MNU_COMPILE_AS; HMENU MNU_MANUAL; HMENU MNU_ABOUT; -HMENU MNU_ADV_SIMULATION; - // scrollbars for the ladder logic area -static HWND HorizScrollBar; -static HWND VertScrollBar; +// static HWND HorizScrollBar; +// static HWND VertScrollBar; int ScrollWidth; int ScrollHeight; BOOL NeedHoriz; // status bar at the bottom of the screen, to display settings -static HWND StatusBar; +// static HWND StatusBar; // have to get back to the menus to gray/ungray, check/uncheck things -static HMENU FileMenu; -static HMENU EditMenu; -static HMENU InstructionMenu; -static HMENU ProcessorMenu; -static HMENU SimulateMenu; -static HMENU TopMenu; +// static HMENU FileMenu; +// static HMENU EditMenu; +// static HMENU InstructionMenu; +// static HMENU ProcessorMenu; +// static HMENU SimulateMenu; +// static HMENU TopMenu; // listview used to maintain the list of I/O pins with symbolic names, plus // the internal relay too -HWND IoList; +// HWND IoList; static int IoListSelectionPoint; static BOOL IoListOutOfSync; int IoListHeight; @@ -137,91 +135,91 @@ static BOOL RealTimeSimulationRunning; //----------------------------------------------------------------------------- void MakeMainWindowControls(void) { - GtkWidget* PackBox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); - GtkWidget* grid = gtk_grid_new(); - GtkWidget* pane = gtk_paned_new (GTK_ORIENTATION_VERTICAL); - GtkListStore* IoList = gtk_list_store_new (5, - G_TYPE_STRING, - G_TYPE_STRING, - G_TYPE_STRING, - G_TYPE_STRING, - G_TYPE_STRING); - GtkWidget* view; - GtkTreeViewColumn* column; - - int typeWidth = 85; - int pinWidth = 100; - int portWidth = 90; - - // Creating a list - view = gtk_tree_view_new_with_model (GTK_TREE_MODEL(IoList)); - gtk_tree_view_set_model (GTK_TREE_VIEW (view), GTK_TREE_MODEL (IoList)); - - column = gtk_tree_view_column_new_with_attributes("Name", - gtk_cell_renderer_text_new(), - "text", LV_IO_NAME, - NULL); - gtk_tree_view_append_column(GTK_TREE_VIEW(view), column); - gtk_tree_view_column_set_min_width (column, 250); - - column = gtk_tree_view_column_new_with_attributes("Type", - gtk_cell_renderer_spin_new(), - "text", LV_IO_TYPE, - NULL); - gtk_tree_view_append_column(GTK_TREE_VIEW(view), column); - gtk_tree_view_column_set_min_width (column, typeWidth); - - column = gtk_tree_view_column_new_with_attributes("State", - gtk_cell_renderer_text_new(), - "text", LV_IO_STATE, - NULL); - gtk_tree_view_append_column(GTK_TREE_VIEW(view), column); - gtk_tree_view_column_set_min_width (column, 100); - - column = gtk_tree_view_column_new_with_attributes("Pin on Processor", - gtk_cell_renderer_text_new(), - "text", LV_IO_PIN, - NULL); - gtk_tree_view_append_column(GTK_TREE_VIEW(view), column); - gtk_tree_view_column_set_min_width (column, pinWidth); - - column = gtk_tree_view_column_new_with_attributes("MCU Port", - gtk_cell_renderer_text_new(), - "text", LV_IO_PORT, - NULL); - gtk_tree_view_append_column(GTK_TREE_VIEW(view), column); - gtk_tree_view_column_set_min_width (column, portWidth); - - // Appending Menus to grid - gtk_grid_attach (GTK_GRID (grid), MakeMainWindowMenus(), 0, 0, 1, 1); - - // Creating Scrolled Window - GtkWidget* ScrollWindow = gtk_scrolled_window_new (NULL, NULL); - gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (ScrollWindow), - GTK_POLICY_AUTOMATIC, - GTK_POLICY_ALWAYS); - - // Creating a pane to separate Scrolled Window and other widgets - gtk_paned_add1 (GTK_PANED (pane), ScrollWindow); - gtk_paned_set_position (GTK_PANED (pane), 0); - gtk_widget_set_vexpand (ScrollWindow, TRUE); - gtk_widget_set_hexpand (ScrollWindow, TRUE); - - // Appending tree view to pane and pane to grid - gtk_paned_add2 (GTK_PANED(pane), view); - gtk_paned_set_position (GTK_PANED (pane), 250); - gtk_grid_attach (GTK_GRID (grid), pane, 0, 0, 1, 1); - - // Creating Status Bar and attaching to grid - StatusBar = gtk_statusbar_new(); - gtk_statusbar_push (GTK_STATUSBAR (StatusBar), - gtk_statusbar_get_context_id (GTK_STATUSBAR (StatusBar), "Introduction"), - "LDMicro Started"); - - // Appneding Status Bar to box which is then added to Main Window - gtk_box_pack_start(GTK_BOX(PackBox), grid, TRUE, TRUE, 0); - gtk_box_pack_start(GTK_BOX(PackBox), StatusBar, FALSE, FALSE, 0); - gtk_container_add(GTK_CONTAINER(MainWindow), PackBox); + // GtkWidget* PackBox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); + // GtkWidget* grid = gtk_grid_new(); + // GtkWidget* pane = gtk_paned_new (GTK_ORIENTATION_VERTICAL); + // GtkListStore* IoList = gtk_list_store_new (5, + // G_TYPE_STRING, + // G_TYPE_STRING, + // G_TYPE_STRING, + // G_TYPE_STRING, + // G_TYPE_STRING); + // GtkWidget* view; + // GtkTreeViewColumn* column; + + // int typeWidth = 85; + // int pinWidth = 100; + // int portWidth = 90; + + // // Creating a list + // view = gtk_tree_view_new_with_model (GTK_TREE_MODEL(IoList)); + // gtk_tree_view_set_model (GTK_TREE_VIEW (view), GTK_TREE_MODEL (IoList)); + + // column = gtk_tree_view_column_new_with_attributes("Name", + // gtk_cell_renderer_text_new(), + // "text", LV_IO_NAME, + // NULL); + // gtk_tree_view_append_column(GTK_TREE_VIEW(view), column); + // gtk_tree_view_column_set_min_width (column, 250); + + // column = gtk_tree_view_column_new_with_attributes("Type", + // gtk_cell_renderer_spin_new(), + // "text", LV_IO_TYPE, + // NULL); + // gtk_tree_view_append_column(GTK_TREE_VIEW(view), column); + // gtk_tree_view_column_set_min_width (column, typeWidth); + + // column = gtk_tree_view_column_new_with_attributes("State", + // gtk_cell_renderer_text_new(), + // "text", LV_IO_STATE, + // NULL); + // gtk_tree_view_append_column(GTK_TREE_VIEW(view), column); + // gtk_tree_view_column_set_min_width (column, 100); + + // column = gtk_tree_view_column_new_with_attributes("Pin on Processor", + // gtk_cell_renderer_text_new(), + // "text", LV_IO_PIN, + // NULL); + // gtk_tree_view_append_column(GTK_TREE_VIEW(view), column); + // gtk_tree_view_column_set_min_width (column, pinWidth); + + // column = gtk_tree_view_column_new_with_attributes("MCU Port", + // gtk_cell_renderer_text_new(), + // "text", LV_IO_PORT, + // NULL); + // gtk_tree_view_append_column(GTK_TREE_VIEW(view), column); + // gtk_tree_view_column_set_min_width (column, portWidth); + + // // Appending Menus to grid + // gtk_grid_attach (GTK_GRID (grid), MakeMainWindowMenus(), 0, 0, 1, 1); + + // // Creating Scrolled Window + // GtkWidget* ScrollWindow = gtk_scrolled_window_new (NULL, NULL); + // gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (ScrollWindow), + // GTK_POLICY_AUTOMATIC, + // GTK_POLICY_ALWAYS); + + // // Creating a pane to separate Scrolled Window and other widgets + // gtk_paned_add1 (GTK_PANED (pane), ScrollWindow); + // gtk_paned_set_position (GTK_PANED (pane), 0); + // gtk_widget_set_vexpand (ScrollWindow, TRUE); + // gtk_widget_set_hexpand (ScrollWindow, TRUE); + + // // Appending tree view to pane and pane to grid + // gtk_paned_add2 (GTK_PANED(pane), view); + // gtk_paned_set_position (GTK_PANED (pane), 250); + // gtk_grid_attach (GTK_GRID (grid), pane, 0, 0, 1, 1); + + // // Creating Status Bar and attaching to grid + // StatusBar = gtk_statusbar_new(); + // gtk_statusbar_push (GTK_STATUSBAR (StatusBar), + // gtk_statusbar_get_context_id (GTK_STATUSBAR (StatusBar), "Introduction"), + // "LDMicro Started"); + + // // Appneding Status Bar to box which is then added to Main Window + // gtk_box_pack_start(GTK_BOX(PackBox), grid, TRUE, TRUE, 0); + // gtk_box_pack_start(GTK_BOX(PackBox), StatusBar, FALSE, FALSE, 0); + // gtk_container_add(GTK_CONTAINER(MainWindow), PackBox); } //----------------------------------------------------------------------------- @@ -230,24 +228,23 @@ void MakeMainWindowControls(void) //----------------------------------------------------------------------------- void UpdateMainWindowTitleBar(void) { - char line[PATH_MAX+100]; - if(InSimulationMode) { - if(RealTimeSimulationRunning) { - strcpy(line, "LDmicro - Simulation (Running)"); - } else { - strcpy(line, "LDmicro - Simulation (Stopped)"); - } - } else { - strcpy(line, "LDmicro - Program Editor"); - } - if(strlen(CurrentSaveFile) > 0) { - sprintf(line+strlen(line), " - %s", CurrentSaveFile); - } else { - strcat(line, " - (not yet saved)"); - } +// char line[PATH_MAX+100]; +// if(InSimulationMode) { +// if(RealTimeSimulationRunning) { +// strcpy(line, "LDmicro - Simulation (Running)"); +// } else { +// strcpy(line, "LDmicro - Simulation (Stopped)"); +// } +// } else { +// strcpy(line, "LDmicro - Program Editor"); +// } +// if(strlen(CurrentSaveFile) > 0) { +// sprintf(line+strlen(line), " - %s", CurrentSaveFile); +// } else { +// strcat(line, " - (not yet saved)"); +// } - gtk_window_set_title (GTK_WINDOW (window), line); - +// gtk_window_set_title (GTK_WINDOW (window), line); } //----------------------------------------------------------------------------- @@ -258,66 +255,66 @@ void SetMenusEnabled(BOOL canNegate, BOOL canNormal, BOOL canResetOnly, BOOL canSetOnly, BOOL canDelete, BOOL canInsertEnd, BOOL canInsertOther, BOOL canPushDown, BOOL canPushUp, BOOL canInsertComment) { - EnableMenuItem(EditMenu, MNU_PUSH_RUNG_UP, - canPushUp ? MF_ENABLED : MF_GRAYED); - EnableMenuItem(EditMenu, MNU_PUSH_RUNG_DOWN, - canPushDown ? MF_ENABLED : MF_GRAYED); - EnableMenuItem(EditMenu, MNU_DELETE_RUNG, - (Prog.numRungs > 1) ? MF_ENABLED : MF_GRAYED); - - EnableMenuItem(InstructionMenu, MNU_NEGATE, - canNegate ? MF_ENABLED : MF_GRAYED); - EnableMenuItem(InstructionMenu, MNU_MAKE_NORMAL, - canNormal ? MF_ENABLED : MF_GRAYED); - EnableMenuItem(InstructionMenu, MNU_MAKE_RESET_ONLY, - canResetOnly ? MF_ENABLED : MF_GRAYED); - EnableMenuItem(InstructionMenu, MNU_MAKE_SET_ONLY, - canSetOnly ? MF_ENABLED : MF_GRAYED); - - EnableMenuItem(InstructionMenu, MNU_INSERT_COMMENT, - canInsertComment ? MF_ENABLED : MF_GRAYED); - - EnableMenuItem(EditMenu, MNU_DELETE_ELEMENT, - canDelete ? MF_ENABLED : MF_GRAYED); - - int t; - t = canInsertEnd ? MF_ENABLED : MF_GRAYED; - EnableMenuItem(InstructionMenu, MNU_INSERT_COIL, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_RES, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_MOV, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_ADD, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_SUB, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_MUL, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_DIV, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_CTC, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_PERSIST, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_READ_ADC, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_SET_PWM, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_MASTER_RLY, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_SHIFT_REG, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_LUT, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_PWL, t); - - t = canInsertOther ? MF_ENABLED : MF_GRAYED; - EnableMenuItem(InstructionMenu, MNU_INSERT_TON, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_TOF, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_OSR, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_OSF, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_RTO, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_CONTACTS, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_CTU, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_CTD, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_EQU, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_NEQ, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_GRT, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_GEQ, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_LES, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_LEQ, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_SHORT, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_OPEN, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_UART_SEND, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_UART_RECV, t); - EnableMenuItem(InstructionMenu, MNU_INSERT_FMTD_STR, t); + // EnableMenuItem(EditMenu, MNU_PUSH_RUNG_UP, + // canPushUp ? MF_ENABLED : MF_GRAYED); + // EnableMenuItem(EditMenu, MNU_PUSH_RUNG_DOWN, + // canPushDown ? MF_ENABLED : MF_GRAYED); + // EnableMenuItem(EditMenu, MNU_DELETE_RUNG, + // (Prog.numRungs > 1) ? MF_ENABLED : MF_GRAYED); + + // EnableMenuItem(InstructionMenu, MNU_NEGATE, + // canNegate ? MF_ENABLED : MF_GRAYED); + // EnableMenuItem(InstructionMenu, MNU_MAKE_NORMAL, + // canNormal ? MF_ENABLED : MF_GRAYED); + // EnableMenuItem(InstructionMenu, MNU_MAKE_RESET_ONLY, + // canResetOnly ? MF_ENABLED : MF_GRAYED); + // EnableMenuItem(InstructionMenu, MNU_MAKE_SET_ONLY, + // canSetOnly ? MF_ENABLED : MF_GRAYED); + + // EnableMenuItem(InstructionMenu, MNU_INSERT_COMMENT, + // canInsertComment ? MF_ENABLED : MF_GRAYED); + + // EnableMenuItem(EditMenu, MNU_DELETE_ELEMENT, + // canDelete ? MF_ENABLED : MF_GRAYED); + + // int t; + // t = canInsertEnd ? MF_ENABLED : MF_GRAYED; + // EnableMenuItem(InstructionMenu, MNU_INSERT_COIL, t); + // EnableMenuItem(InstructionMenu, MNU_INSERT_RES, t); + // EnableMenuItem(InstructionMenu, MNU_INSERT_MOV, t); + // EnableMenuItem(InstructionMenu, MNU_INSERT_ADD, t); + // EnableMenuItem(InstructionMenu, MNU_INSERT_SUB, t); + // EnableMenuItem(InstructionMenu, MNU_INSERT_MUL, t); + // EnableMenuItem(InstructionMenu, MNU_INSERT_DIV, t); + // EnableMenuItem(InstructionMenu, MNU_INSERT_CTC, t); + // EnableMenuItem(InstructionMenu, MNU_INSERT_PERSIST, t); + // EnableMenuItem(InstructionMenu, MNU_INSERT_READ_ADC, t); + // EnableMenuItem(InstructionMenu, MNU_INSERT_SET_PWM, t); + // EnableMenuItem(InstructionMenu, MNU_INSERT_MASTER_RLY, t); + // EnableMenuItem(InstructionMenu, MNU_INSERT_SHIFT_REG, t); + // EnableMenuItem(InstructionMenu, MNU_INSERT_LUT, t); + // EnableMenuItem(InstructionMenu, MNU_INSERT_PWL, t); + + // t = canInsertOther ? MF_ENABLED : MF_GRAYED; + // EnableMenuItem(InstructionMenu, MNU_INSERT_TON, t); + // EnableMenuItem(InstructionMenu, MNU_INSERT_TOF, t); + // EnableMenuItem(InstructionMenu, MNU_INSERT_OSR, t); + // EnableMenuItem(InstructionMenu, MNU_INSERT_OSF, t); + // EnableMenuItem(InstructionMenu, MNU_INSERT_RTO, t); + // EnableMenuItem(InstructionMenu, MNU_INSERT_CONTACTS, t); + // EnableMenuItem(InstructionMenu, MNU_INSERT_CTU, t); + // EnableMenuItem(InstructionMenu, MNU_INSERT_CTD, t); + // EnableMenuItem(InstructionMenu, MNU_INSERT_EQU, t); + // EnableMenuItem(InstructionMenu, MNU_INSERT_NEQ, t); + // EnableMenuItem(InstructionMenu, MNU_INSERT_GRT, t); + // EnableMenuItem(InstructionMenu, MNU_INSERT_GEQ, t); + // EnableMenuItem(InstructionMenu, MNU_INSERT_LES, t); + // EnableMenuItem(InstructionMenu, MNU_INSERT_LEQ, t); + // EnableMenuItem(InstructionMenu, MNU_INSERT_SHORT, t); + // EnableMenuItem(InstructionMenu, MNU_INSERT_OPEN, t); + // EnableMenuItem(InstructionMenu, MNU_INSERT_UART_SEND, t); + // EnableMenuItem(InstructionMenu, MNU_INSERT_UART_RECV, t); + // EnableMenuItem(InstructionMenu, MNU_INSERT_FMTD_STR, t); } //----------------------------------------------------------------------------- @@ -325,285 +322,282 @@ void SetMenusEnabled(BOOL canNegate, BOOL canNormal, BOOL canResetOnly, //----------------------------------------------------------------------------- void SetUndoEnabled(BOOL undoEnabled, BOOL redoEnabled) { - EnableMenuItem(EditMenu, MNU_UNDO, undoEnabled ? MF_ENABLED : MF_GRAYED); - EnableMenuItem(EditMenu, MNU_REDO, redoEnabled ? MF_ENABLED : MF_GRAYED); + // EnableMenuItem(EditMenu, MNU_UNDO, undoEnabled ? MF_ENABLED : MF_GRAYED); + // EnableMenuItem(EditMenu, MNU_REDO, redoEnabled ? MF_ENABLED : MF_GRAYED); } //----------------------------------------------------------------------------- // Create the top-level menu bar for the main window. Mostly static, but we // create the "select processor" menu from the list in mcutable.h dynamically. //----------------------------------------------------------------------------- - HMENU MakeMainWindowMenus(void) { - HMENU MenuBox; // Box for alignment - HMENU PackedMenuBox; // Stores the packed box - HMENU TopMenu; // Menu Bar - HWID FileLabel; // File menu label - HWID EditLabel; // Edit menu label - HWID InstructionLabel; // Instruction menu label - HWID SettingsLabel; // Settings menu label - HWID CompileLabel; // Compile menu label - HWID HelpLabel; // Help menu label - HWID SimulateLabel; // Simulate menu label - // HMENU file_menu_items; // File menu item - // HMENU edit_menu_items; // Edit menu item - // HMENU instruction_menu_items; // Instruction menu item - // HMENU settings_menu_items; // Settings menu item - HMENU ProcessorMenuItems; // Processor menu items - // HMENU compile_menu_items; // Compile menu item - // HMENU help_menu_items; // Help menu item - // HMENU simulate_menu_items; // Simulate menu item - HMENU FileMenuSeparator; // File menu separator - HMENU EditMenuSeparator; // Edit menu separator - HMENU InstructionMenuSeparator; // Instruction menu separator - HMENU SimulateMenuSeparator; // Simulate menu separator - - int i; - // Creating a box for desired orientation - MenuBox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); - - // Create new menu bar to hold menu and add it to window - TopMenu = gtk_menu_bar_new(); - - // Creating various menus - FileMenu = gtk_menu_new(); - EditMenu = gtk_menu_new(); - settings = gtk_menu_new(); - ProcessorMenu = gtk_menu_new(); - InstructionMenu = gtk_menu_new(); - SimulateMenu = gtk_menu_new(); - compile = gtk_menu_new(); - help = gtk_menu_new(); - - // Creating labels for each menu - FileLabel = gtk_menu_item_new_with_label("File"); - EditLabel = gtk_menu_item_new_with_label("Edit"); - SettingsLabel = gtk_menu_item_new_with_label("Settings"); - InstructionLabel = gtk_menu_item_new_with_label("Instructions"); - SimulateLabel = gtk_menu_item_new_with_label("Simulate"); - CompileLabel = gtk_menu_item_new_with_label("Compile"); - HelpLabel = gtk_menu_item_new_with_label("Help"); - - // Creating labels for File Menu - MNU_NEW = gtk_menu_item_new_with_label("New"); - MNU_OPEN = gtk_menu_item_new_with_label("Open"); - MNU_SAVE = gtk_menu_item_new_with_label("Save"); - MNU_SAVE_AS = gtk_menu_item_new_with_label("Save As"); - MNU_EXPORT = gtk_menu_item_new_with_label("Export As Text"); - MNU_EXIT = gtk_menu_item_new_with_label("Exit"); + // HMENU MenuBox; // Box for alignment + // HMENU PackedMenuBox; // Stores the packed box + // HMENU TopMenu; // Menu Bar + // HWID FileLabel; // File menu label + // HWID EditLabel; // Edit menu label + // HWID InstructionLabel; // Instruction menu label + // HWID SettingsLabel; // Settings menu label + // HWID CompileLabel; // Compile menu label + // HWID HelpLabel; // Help menu label + // HWID SimulateLabel; // Simulate menu label + // // HMENU file_menu_items; // File menu item + // // HMENU edit_menu_items; // Edit menu item + // // HMENU instruction_menu_items; // Instruction menu item + // // HMENU settings_menu_items; // Settings menu item + // HMENU ProcessorMenuItems; // Processor menu items + // // HMENU compile_menu_items; // Compile menu item + // // HMENU help_menu_items; // Help menu item + // // HMENU simulate_menu_items; // Simulate menu item + // HMENU FileMenuSeparator; // File menu separator + // HMENU EditMenuSeparator; // Edit menu separator + // HMENU InstructionMenuSeparator; // Instruction menu separator + // HMENU SimulateMenuSeparator; // Simulate menu separator + + // int i; + // // Creating a box for desired orientation + // MenuBox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0); + + // // Create new menu bar to hold menu and add it to window + // TopMenu = gtk_menu_bar_new(); + + // // Creating various menus + // FileMenu = gtk_menu_new(); + // EditMenu = gtk_menu_new(); + // settings = gtk_menu_new(); + // ProcessorMenu = gtk_menu_new(); + // InstructionMenu = gtk_menu_new(); + // SimulateMenu = gtk_menu_new(); + // compile = gtk_menu_new(); + // help = gtk_menu_new(); + + // // Creating labels for each menu + // FileLabel = gtk_menu_item_new_with_label("File"); + // EditLabel = gtk_menu_item_new_with_label("Edit"); + // SettingsLabel = gtk_menu_item_new_with_label("Settings"); + // InstructionLabel = gtk_menu_item_new_with_label("Instructions"); + // SimulateLabel = gtk_menu_item_new_with_label("Simulate"); + // CompileLabel = gtk_menu_item_new_with_label("Compile"); + // HelpLabel = gtk_menu_item_new_with_label("Help"); + + // // Creating labels for File Menu + // MNU_NEW = gtk_menu_item_new_with_label("New"); + // MNU_OPEN = gtk_menu_item_new_with_label("Open"); + // MNU_SAVE = gtk_menu_item_new_with_label("Save"); + // MNU_SAVE_AS = gtk_menu_item_new_with_label("Save As"); + // MNU_EXPORT = gtk_menu_item_new_with_label("Export As Text"); + // MNU_EXIT = gtk_menu_item_new_with_label("Exit"); - // Appending menu items (labels) to File menu and adding separators - gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), MNU_NEW); // Appending menu items - gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), MNU_OPEN); - gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), MNU_SAVE); - gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), MNU_SAVE_AS); - FileMenuSeparator = gtk_separator_menu_item_new(); - gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), FileMenuSeparator); - gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), MNU_EXPORT); - FileMenuSeparator = gtk_separator_menu_item_new(); - gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), FileMenuSeparator); - gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), MNU_EXIT); - - // Creating labels for Edit Menu - MNU_UNDO = gtk_menu_item_new_with_label("Undo"); - MNU_REDO = gtk_menu_item_new_with_label("Redo"); - MNU_INSERT_RUNG_BEFORE = gtk_menu_item_new_with_label("Insert rung Before"); - MNU_INSERT_RUNG_AFTER = gtk_menu_item_new_with_label("Insert Rung After"); - MNU_PUSH_RUNG_UP = gtk_menu_item_new_with_label("Move Selected Rung Up"); - MNU_PUSH_RUNG_DOWN = gtk_menu_item_new_with_label("Move Selected Rung Down"); - MNU_DELETE_ELEMENT = gtk_menu_item_new_with_label("Delete Selected Element"); - MNU_DELETE_RUNG = gtk_menu_item_new_with_label("Delete Rung"); - - // Appending menu items to Edit menu and adding separators - gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), MNU_UNDO); - gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), MNU_REDO); - EditMenuSeparator = gtk_separator_menu_item_new(); - gtk_menu_shell_append(GTK_MENU_SHELL(EditMenu), EditMenuSeparator); - gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), MNU_INSERT_RUNG_BEFORE); - gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), MNU_INSERT_RUNG_AFTER); - gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), MNU_PUSH_RUNG_UP); - gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), MNU_PUSH_RUNG_DOWN); - EditMenuSeparator = gtk_separator_menu_item_new(); - gtk_menu_shell_append(GTK_MENU_SHELL(EditMenu), EditMenuSeparator); - gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), MNU_DELETE_ELEMENT); - gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), MNU_DELETE_RUNG); - - // Creating labels for Settings Menu - MNU_MCU_SETTINGS = gtk_menu_item_new_with_label ("MCU Parameters..."); - MNU_PROCESSOR_0 = gtk_menu_item_new_with_label ("Microcontroller"); - - // Appending menu items to Settings menu - gtk_menu_shell_append (GTK_MENU_SHELL (settings), MNU_MCU_SETTINGS); - gtk_menu_shell_append (GTK_MENU_SHELL (settings), MNU_PROCESSOR_0); - - for (i = 0; i < NUM_SUPPORTED_MCUS; i++){ - ProcessorMenuItems = gtk_check_menu_item_new_with_label (SupportedMcus[i].mcuName); - gtk_menu_shell_append (GTK_MENU_SHELL (ProcessorMenu), ProcessorMenuItems); - } - - ProcessorMenuItems = gtk_check_menu_item_new_with_label ("(no microcontroller)"); - gtk_menu_shell_append (GTK_MENU_SHELL (ProcessorMenu), ProcessorMenuItems); - gtk_menu_item_set_submenu(GTK_MENU_ITEM(MNU_PROCESSOR_0), ProcessorMenu); - - // Creating labels for Instruction Menu and adding separators - MNU_INSERT_COMMENT = gtk_menu_item_new_with_label("Insert Comment"); - MNU_INSERT_CONTACTS = gtk_menu_item_new_with_label("Insert Contacts"); - MNU_INSERT_OSR = gtk_menu_item_new_with_label("Insert OSR (One Shot Rising)"); - MNU_INSERT_OSF = gtk_menu_item_new_with_label("Insert OSF (One Shot Falling)"); - MNU_INSERT_TON = gtk_menu_item_new_with_label("Insert TON (Delayed Turn On)"); - MNU_INSERT_TOF = gtk_menu_item_new_with_label("Insert TOF (Delayed Turn Off)"); - MNU_INSERT_RTO = gtk_menu_item_new_with_label("Insert RTO (Retentive Delayed Turn On)"); - MNU_INSERT_CTU = gtk_menu_item_new_with_label("Insert CTU (Count Up)"); - MNU_INSERT_CTD = gtk_menu_item_new_with_label("Insert CTD (Count Down)"); - MNU_INSERT_CTC = gtk_menu_item_new_with_label("Insert CTC (Count Circular)"); - MNU_INSERT_EQU = gtk_menu_item_new_with_label("Insert EQU (Compare for Equals)"); - MNU_INSERT_NEQ = gtk_menu_item_new_with_label("Insert NEQ (Compare for Not Equals)"); - MNU_INSERT_GRT = gtk_menu_item_new_with_label("Insert GRT (Compare for Greater Than)"); - MNU_INSERT_GEQ = gtk_menu_item_new_with_label("Insert GEQ (Compare for Greater Than or Equal)"); - MNU_INSERT_LES = gtk_menu_item_new_with_label("Insert LES (Compare for Less Than)"); - MNU_INSERT_LEQ = gtk_menu_item_new_with_label("Insert LEQ (Compare for Less Than or Equal)"); - MNU_INSERT_OPEN = gtk_menu_item_new_with_label("Insert Open Circuit"); - MNU_INSERT_SHORT = gtk_menu_item_new_with_label("Insert Short Circuit"); - MNU_INSERT_MASTER_RLY = gtk_menu_item_new_with_label("Insert Master Control Relay"); - MNU_INSERT_COIL = gtk_menu_item_new_with_label("Insert Coil"); - MNU_INSERT_RES = gtk_menu_item_new_with_label("Insert RES (Counter/RTO Reset)"); - MNU_INSERT_MOV = gtk_menu_item_new_with_label("Insert MOV (Move)"); - MNU_INSERT_ADD = gtk_menu_item_new_with_label("Insert ADD (16-bit Integer Ad)"); - MNU_INSERT_SUB = gtk_menu_item_new_with_label("Insert SUB (16-bit Integer Subtract)"); - MNU_INSERT_MUL = gtk_menu_item_new_with_label("Insert MUL (16-bit Integer Multiply)"); - MNU_INSERT_DIV = gtk_menu_item_new_with_label("Insert DIV (16-bit Integer Division)"); - MNU_INSERT_SHIFT_REG = gtk_menu_item_new_with_label("Insert Shift Register"); - MNU_INSERT_LUT = gtk_menu_item_new_with_label("Insert Look-Up Table"); - MNU_INSERT_PWL = gtk_menu_item_new_with_label("Insert Piecewise Linear"); - MNU_INSERT_FMTD_STR = gtk_menu_item_new_with_label("Insert Formatted String Over UART"); - MNU_INSERT_UART_SEND = gtk_menu_item_new_with_label("Insert UART Send"); - MNU_INSERT_UART_RECV = gtk_menu_item_new_with_label("Insert UART Receive"); - MNU_INSERT_SET_PWM = gtk_menu_item_new_with_label("Insert Set PWM Output"); - MNU_INSERT_READ_ADC = gtk_menu_item_new_with_label("Insert A/D Converter Read"); - MNU_INSERT_PERSIST = gtk_menu_item_new_with_label("Insert Make Persistent"); - MNU_MAKE_NORMAL = gtk_menu_item_new_with_label("Make Normal"); - MNU_NEGATE = gtk_menu_item_new_with_label("Make Negated"); - MNU_MAKE_SET_ONLY = gtk_menu_item_new_with_label("Make Set-Only"); - MNU_MAKE_RESET_ONLY = gtk_menu_item_new_with_label("Make Reset-Only"); - - // Appending menu items to Instruction menu and adding separators - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_COMMENT); - InstructionMenuSeparator = gtk_separator_menu_item_new(); - gtk_menu_shell_append (GTK_MENU_SHELL(InstructionMenu), InstructionMenuSeparator); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_CONTACTS); - InstructionMenuSeparator = gtk_separator_menu_item_new(); - gtk_menu_shell_append (GTK_MENU_SHELL(InstructionMenu), InstructionMenuSeparator); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_OSR); - InstructionMenuSeparator = gtk_separator_menu_item_new(); - gtk_menu_shell_append (GTK_MENU_SHELL(InstructionMenu), InstructionMenuSeparator); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_OSF); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_TON); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_TOF); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_RTO); - InstructionMenuSeparator = gtk_separator_menu_item_new(); - gtk_menu_shell_append (GTK_MENU_SHELL(InstructionMenu), InstructionMenuSeparator); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_CTU); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_CTD); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_CTC); - InstructionMenuSeparator = gtk_separator_menu_item_new(); - gtk_menu_shell_append (GTK_MENU_SHELL(InstructionMenu), InstructionMenuSeparator); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_EQU); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_NEQ); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_GRT); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_GEQ); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_LES); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_LEQ); - InstructionMenuSeparator = gtk_separator_menu_item_new(); - gtk_menu_shell_append (GTK_MENU_SHELL(InstructionMenu), InstructionMenuSeparator); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_OPEN); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_SHORT); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_MASTER_RLY); - InstructionMenuSeparator = gtk_separator_menu_item_new(); - gtk_menu_shell_append (GTK_MENU_SHELL(InstructionMenu), InstructionMenuSeparator); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_COIL); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_RES); - InstructionMenuSeparator = gtk_separator_menu_item_new(); - gtk_menu_shell_append (GTK_MENU_SHELL(InstructionMenu), InstructionMenuSeparator); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_MOV); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_ADD); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_SUB); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_MUL); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_DIV); - InstructionMenuSeparator = gtk_separator_menu_item_new(); - gtk_menu_shell_append (GTK_MENU_SHELL(InstructionMenu), InstructionMenuSeparator); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_SHIFT_REG); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_LUT); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_PWL); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_FMTD_STR); - InstructionMenuSeparator = gtk_separator_menu_item_new(); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InstructionMenuSeparator); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_UART_SEND); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_UART_RECV); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_SET_PWM); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_READ_ADC); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_PERSIST); - InstructionMenuSeparator = gtk_separator_menu_item_new(); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InstructionMenuSeparator); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_MAKE_NORMAL); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_NEGATE); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_MAKE_SET_ONLY); - gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_MAKE_RESET_ONLY); - - // Creating labels for Simulation Menu - MNU_COMPILE = gtk_menu_item_new_with_label("Compile"); - MNU_COMPILE_AS = gtk_menu_item_new_with_label("Compile As..."); - - // Appending menu items to Compile menu - gtk_menu_shell_append(GTK_MENU_SHELL (compile), MNU_COMPILE); - gtk_menu_shell_append(GTK_MENU_SHELL (compile), MNU_COMPILE_AS); - - // Creating labels for Simulation Menu - MNU_MANUAL = gtk_menu_item_new_with_label("Manual..."); - MNU_ABOUT = gtk_menu_item_new_with_label("About..."); - - // Appending menu items to Help menu - gtk_menu_shell_append(GTK_MENU_SHELL (help), MNU_MANUAL); - gtk_menu_shell_append(GTK_MENU_SHELL (help), MNU_ABOUT); - - // Creating labels for Simulation Menu - MNU_SIMULATION_MODE = gtk_check_menu_item_new_with_label("Simulation Mode"); - MNU_START_SIMULATION = gtk_menu_item_new_with_label("Start Real-Time Simulation"); - MNU_STOP_SIMULATION = gtk_menu_item_new_with_label("Halt Simulation"); - MNU_SINGLE_CYCLE = gtk_menu_item_new_with_label("Single Cycle"); - MNU_ADV_SIMULATION = gtk_menu_item_new_with_label("Advanced Simulation"); - - // Appending menu items to Simulate menu and adding separators - gtk_menu_shell_append(GTK_MENU_SHELL (SimulateMenu), MNU_SIMULATION_MODE); - gtk_menu_shell_append(GTK_MENU_SHELL (SimulateMenu), MNU_START_SIMULATION); - gtk_menu_shell_append(GTK_MENU_SHELL (SimulateMenu), MNU_STOP_SIMULATION); - gtk_menu_shell_append(GTK_MENU_SHELL (SimulateMenu), MNU_SINGLE_CYCLE); - SimulateMenuSeparator = gtk_separator_menu_item_new(); - gtk_menu_shell_append(GTK_MENU_SHELL(SimulateMenu), SimulateMenuSeparator); - gtk_menu_shell_append(GTK_MENU_SHELL (SimulateMenu), MNU_ADV_SIMULATION); - - // Creating submenus for each menu - gtk_menu_item_set_submenu(GTK_MENU_ITEM(FileLabel), FileMenu); - gtk_menu_item_set_submenu(GTK_MENU_ITEM(EditLabel), EditMenu); - gtk_menu_item_set_submenu(GTK_MENU_ITEM(SettingsLabel), settings); - gtk_menu_item_set_submenu(GTK_MENU_ITEM(InstructionLabel), InstructionMenu); - gtk_menu_item_set_submenu(GTK_MENU_ITEM(SimulateLabel), SimulateMenu); - gtk_menu_item_set_submenu(GTK_MENU_ITEM(CompileLabel), compile); - gtk_menu_item_set_submenu(GTK_MENU_ITEM(HelpLabel), help); - - // Appending the menu item to the menu bar - gtk_menu_shell_append(GTK_MENU_SHELL(TopMenu), FileLabel); - gtk_menu_shell_append(GTK_MENU_SHELL(TopMenu), EditLabel); - gtk_menu_shell_append(GTK_MENU_SHELL(TopMenu), SettingsLabel); - gtk_menu_shell_append(GTK_MENU_SHELL(TopMenu), InstructionLabel); - gtk_menu_shell_append(GTK_MENU_SHELL(TopMenu), SimulateLabel); - gtk_menu_shell_append(GTK_MENU_SHELL(TopMenu), CompileLabel); - gtk_menu_shell_append(GTK_MENU_SHELL(TopMenu), HelpLabel); - - // Packing the menu bar into the box for alignment - gtk_box_pack_start(GTK_BOX(MenuBox), TopMenu, FALSE, FALSE, 0); - - return MenuBox; + // // Appending menu items (labels) to File menu and adding separators + // gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), MNU_NEW); // Appending menu items + // gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), MNU_OPEN); + // gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), MNU_SAVE); + // gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), MNU_SAVE_AS); + // FileMenuSeparator = gtk_separator_menu_item_new(); + // gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), FileMenuSeparator); + // gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), MNU_EXPORT); + // FileMenuSeparator = gtk_separator_menu_item_new(); + // gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), FileMenuSeparator); + // gtk_menu_shell_append(GTK_MENU_SHELL (FileMenu), MNU_EXIT); + + // // Creating labels for Edit Menu + // MNU_UNDO = gtk_menu_item_new_with_label("Undo"); + // MNU_REDO = gtk_menu_item_new_with_label("Redo"); + // MNU_INSERT_RUNG_BEFORE = gtk_menu_item_new_with_label("Insert rung Before"); + // MNU_INSERT_RUNG_AFTER = gtk_menu_item_new_with_label("Insert Rung After"); + // MNU_PUSH_RUNG_UP = gtk_menu_item_new_with_label("Move Selected Rung Up"); + // MNU_PUSH_RUNG_DOWN = gtk_menu_item_new_with_label("Move Selected Rung Down"); + // MNU_DELETE_ELEMENT = gtk_menu_item_new_with_label("Delete Selected Element"); + // MNU_DELETE_RUNG = gtk_menu_item_new_with_label("Delete Rung"); + + // // Appending menu items to Edit menu and adding separators + // gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), MNU_UNDO); + // gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), MNU_REDO); + // EditMenuSeparator = gtk_separator_menu_item_new(); + // gtk_menu_shell_append(GTK_MENU_SHELL(EditMenu), EditMenuSeparator); + // gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), MNU_INSERT_RUNG_BEFORE); + // gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), MNU_INSERT_RUNG_AFTER); + // gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), MNU_PUSH_RUNG_UP); + // gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), MNU_PUSH_RUNG_DOWN); + // EditMenuSeparator = gtk_separator_menu_item_new(); + // gtk_menu_shell_append(GTK_MENU_SHELL(EditMenu), EditMenuSeparator); + // gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), MNU_DELETE_ELEMENT); + // gtk_menu_shell_append(GTK_MENU_SHELL (EditMenu), MNU_DELETE_RUNG); + + // // Creating labels for Settings Menu + // MNU_MCU_SETTINGS = gtk_menu_item_new_with_label ("MCU Parameters..."); + // MNU_PROCESSOR_0 = gtk_menu_item_new_with_label ("Microcontroller"); + + // // Appending menu items to Settings menu + // gtk_menu_shell_append (GTK_MENU_SHELL (settings), MNU_MCU_SETTINGS); + // gtk_menu_shell_append (GTK_MENU_SHELL (settings), MNU_PROCESSOR_0); + + // for (i = 0; i < NUM_SUPPORTED_MCUS; i++){ + // ProcessorMenuItems = gtk_check_menu_item_new_with_label (SupportedMcus[i].mcuName); + // gtk_menu_shell_append (GTK_MENU_SHELL (ProcessorMenu), ProcessorMenuItems); + // } + + // ProcessorMenuItems = gtk_check_menu_item_new_with_label ("(no microcontroller)"); + // gtk_menu_shell_append (GTK_MENU_SHELL (ProcessorMenu), ProcessorMenuItems); + // gtk_menu_item_set_submenu(GTK_MENU_ITEM(MNU_PROCESSOR_0), ProcessorMenu); + + // // Creating labels for Instruction Menu and adding separators + // MNU_INSERT_COMMENT = gtk_menu_item_new_with_label("Insert Comment"); + // MNU_INSERT_CONTACTS = gtk_menu_item_new_with_label("Insert Contacts"); + // MNU_INSERT_OSR = gtk_menu_item_new_with_label("Insert OSR (One Shot Rising)"); + // MNU_INSERT_OSF = gtk_menu_item_new_with_label("Insert OSF (One Shot Falling)"); + // MNU_INSERT_TON = gtk_menu_item_new_with_label("Insert TON (Delayed Turn On)"); + // MNU_INSERT_TOF = gtk_menu_item_new_with_label("Insert TOF (Delayed Turn Off)"); + // MNU_INSERT_RTO = gtk_menu_item_new_with_label("Insert RTO (Retentive Delayed Turn On)"); + // MNU_INSERT_CTU = gtk_menu_item_new_with_label("Insert CTU (Count Up)"); + // MNU_INSERT_CTD = gtk_menu_item_new_with_label("Insert CTD (Count Down)"); + // MNU_INSERT_CTC = gtk_menu_item_new_with_label("Insert CTC (Count Circular)"); + // MNU_INSERT_EQU = gtk_menu_item_new_with_label("Insert EQU (Compare for Equals)"); + // MNU_INSERT_NEQ = gtk_menu_item_new_with_label("Insert NEQ (Compare for Not Equals)"); + // MNU_INSERT_GRT = gtk_menu_item_new_with_label("Insert GRT (Compare for Greater Than)"); + // MNU_INSERT_GEQ = gtk_menu_item_new_with_label("Insert GEQ (Compare for Greater Than or Equal)"); + // MNU_INSERT_LES = gtk_menu_item_new_with_label("Insert LES (Compare for Less Than)"); + // MNU_INSERT_LEQ = gtk_menu_item_new_with_label("Insert LEQ (Compare for Less Than or Equal)"); + // MNU_INSERT_OPEN = gtk_menu_item_new_with_label("Insert Open Circuit"); + // MNU_INSERT_SHORT = gtk_menu_item_new_with_label("Insert Short Circuit"); + // MNU_INSERT_MASTER_RLY = gtk_menu_item_new_with_label("Insert Master Control Relay"); + // MNU_INSERT_COIL = gtk_menu_item_new_with_label("Insert Coil"); + // MNU_INSERT_RES = gtk_menu_item_new_with_label("Insert RES (Counter/RTO Reset)"); + // MNU_INSERT_MOV = gtk_menu_item_new_with_label("Insert MOV (Move)"); + // MNU_INSERT_ADD = gtk_menu_item_new_with_label("Insert ADD (16-bit Integer Ad)"); + // MNU_INSERT_SUB = gtk_menu_item_new_with_label("Insert SUB (16-bit Integer Subtract)"); + // MNU_INSERT_MUL = gtk_menu_item_new_with_label("Insert MUL (16-bit Integer Multiply)"); + // MNU_INSERT_DIV = gtk_menu_item_new_with_label("Insert DIV (16-bit Integer Division)"); + // MNU_INSERT_SHIFT_REG = gtk_menu_item_new_with_label("Insert Shift Register"); + // MNU_INSERT_LUT = gtk_menu_item_new_with_label("Insert Look-Up Table"); + // MNU_INSERT_PWL = gtk_menu_item_new_with_label("Insert Piecewise Linear"); + // MNU_INSERT_FMTD_STR = gtk_menu_item_new_with_label("Insert Formatted String Over UART"); + // MNU_INSERT_UART_SEND = gtk_menu_item_new_with_label("Insert UART Send"); + // MNU_INSERT_UART_RECV = gtk_menu_item_new_with_label("Insert UART Receive"); + // MNU_INSERT_SET_PWM = gtk_menu_item_new_with_label("Insert Set PWM Output"); + // MNU_INSERT_READ_ADC = gtk_menu_item_new_with_label("Insert A/D Converter Read"); + // MNU_INSERT_PERSIST = gtk_menu_item_new_with_label("Insert Make Persistent"); + // MNU_MAKE_NORMAL = gtk_menu_item_new_with_label("Make Normal"); + // MNU_NEGATE = gtk_menu_item_new_with_label("Make Negated"); + // MNU_MAKE_SET_ONLY = gtk_menu_item_new_with_label("Make Set-Only"); + // MNU_MAKE_RESET_ONLY = gtk_menu_item_new_with_label("Make Reset-Only"); + + // // Appending menu items to Instruction menu and adding separators + // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_COMMENT); + // InstructionMenuSeparator = gtk_separator_menu_item_new(); + // gtk_menu_shell_append (GTK_MENU_SHELL(InstructionMenu), InstructionMenuSeparator); + // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_CONTACTS); + // InstructionMenuSeparator = gtk_separator_menu_item_new(); + // gtk_menu_shell_append (GTK_MENU_SHELL(InstructionMenu), InstructionMenuSeparator); + // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_OSR); + // InstructionMenuSeparator = gtk_separator_menu_item_new(); + // gtk_menu_shell_append (GTK_MENU_SHELL(InstructionMenu), InstructionMenuSeparator); + // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_OSF); + // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_TON); + // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_TOF); + // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_RTO); + // InstructionMenuSeparator = gtk_separator_menu_item_new(); + // gtk_menu_shell_append (GTK_MENU_SHELL(InstructionMenu), InstructionMenuSeparator); + // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_CTU); + // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_CTD); + // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_CTC); + // InstructionMenuSeparator = gtk_separator_menu_item_new(); + // gtk_menu_shell_append (GTK_MENU_SHELL(InstructionMenu), InstructionMenuSeparator); + // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_EQU); + // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_NEQ); + // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_GRT); + // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_GEQ); + // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_LES); + // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_LEQ); + // InstructionMenuSeparator = gtk_separator_menu_item_new(); + // gtk_menu_shell_append (GTK_MENU_SHELL(InstructionMenu), InstructionMenuSeparator); + // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_OPEN); + // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_SHORT); + // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_MASTER_RLY); + // InstructionMenuSeparator = gtk_separator_menu_item_new(); + // gtk_menu_shell_append (GTK_MENU_SHELL(InstructionMenu), InstructionMenuSeparator); + // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_COIL); + // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_RES); + // InstructionMenuSeparator = gtk_separator_menu_item_new(); + // gtk_menu_shell_append (GTK_MENU_SHELL(InstructionMenu), InstructionMenuSeparator); + // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_MOV); + // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_ADD); + // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_SUB); + // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_MUL); + // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_DIV); + // InstructionMenuSeparator = gtk_separator_menu_item_new(); + // gtk_menu_shell_append (GTK_MENU_SHELL(InstructionMenu), InstructionMenuSeparator); + // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_SHIFT_REG); + // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_LUT); + // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_PWL); + // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_FMTD_STR); + // InstructionMenuSeparator = gtk_separator_menu_item_new(); + // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InstructionMenuSeparator); + // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_UART_SEND); + // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_UART_RECV); + // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_SET_PWM); + // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_READ_ADC); + // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_INSERT_PERSIST); + // InstructionMenuSeparator = gtk_separator_menu_item_new(); + // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), InstructionMenuSeparator); + // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_MAKE_NORMAL); + // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_NEGATE); + // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_MAKE_SET_ONLY); + // gtk_menu_shell_append (GTK_MENU_SHELL (InstructionMenu), MNU_MAKE_RESET_ONLY); + + // // Creating labels for Simulation Menu + // MNU_COMPILE = gtk_menu_item_new_with_label("Compile"); + // MNU_COMPILE_AS = gtk_menu_item_new_with_label("Compile As..."); + + // // Appending menu items to Compile menu + // gtk_menu_shell_append(GTK_MENU_SHELL (compile), MNU_COMPILE); + // gtk_menu_shell_append(GTK_MENU_SHELL (compile), MNU_COMPILE_AS); + + // // Creating labels for Simulation Menu + // MNU_MANUAL = gtk_menu_item_new_with_label("Manual..."); + // MNU_ABOUT = gtk_menu_item_new_with_label("About..."); + + // // Appending menu items to Help menu + // gtk_menu_shell_append(GTK_MENU_SHELL (help), MNU_MANUAL); + // gtk_menu_shell_append(GTK_MENU_SHELL (help), MNU_ABOUT); + + // // Creating labels for Simulation Menu + // MNU_SIMULATION_MODE = gtk_check_menu_item_new_with_label("Simulation Mode"); + // MNU_START_SIMULATION = gtk_menu_item_new_with_label("Start Real-Time Simulation"); + // MNU_STOP_SIMULATION = gtk_menu_item_new_with_label("Halt Simulation"); + // MNU_SINGLE_CYCLE = gtk_menu_item_new_with_label("Single Cycle"); + + // // Appending menu items to Simulate menu and adding separators + // gtk_menu_shell_append(GTK_MENU_SHELL (SimulateMenu), MNU_SIMULATION_MODE); + // gtk_menu_shell_append(GTK_MENU_SHELL (SimulateMenu), MNU_START_SIMULATION); + // gtk_menu_shell_append(GTK_MENU_SHELL (SimulateMenu), MNU_STOP_SIMULATION); + // gtk_menu_shell_append(GTK_MENU_SHELL (SimulateMenu), MNU_SINGLE_CYCLE); + // SimulateMenuSeparator = gtk_separator_menu_item_new(); + // gtk_menu_shell_append(GTK_MENU_SHELL(SimulateMenu), SimulateMenuSeparator); + + // // Creating submenus for each menu + // gtk_menu_item_set_submenu(GTK_MENU_ITEM(FileLabel), FileMenu); + // gtk_menu_item_set_submenu(GTK_MENU_ITEM(EditLabel), EditMenu); + // gtk_menu_item_set_submenu(GTK_MENU_ITEM(SettingsLabel), settings); + // gtk_menu_item_set_submenu(GTK_MENU_ITEM(InstructionLabel), InstructionMenu); + // gtk_menu_item_set_submenu(GTK_MENU_ITEM(SimulateLabel), SimulateMenu); + // gtk_menu_item_set_submenu(GTK_MENU_ITEM(CompileLabel), compile); + // gtk_menu_item_set_submenu(GTK_MENU_ITEM(HelpLabel), help); + + // // Appending the menu item to the menu bar + // gtk_menu_shell_append(GTK_MENU_SHELL(TopMenu), FileLabel); + // gtk_menu_shell_append(GTK_MENU_SHELL(TopMenu), EditLabel); + // gtk_menu_shell_append(GTK_MENU_SHELL(TopMenu), SettingsLabel); + // gtk_menu_shell_append(GTK_MENU_SHELL(TopMenu), InstructionLabel); + // gtk_menu_shell_append(GTK_MENU_SHELL(TopMenu), SimulateLabel); + // gtk_menu_shell_append(GTK_MENU_SHELL(TopMenu), CompileLabel); + // gtk_menu_shell_append(GTK_MENU_SHELL(TopMenu), HelpLabel); + + // // Packing the menu bar into the box for alignment + // gtk_box_pack_start(GTK_BOX(MenuBox), TopMenu, FALSE, FALSE, 0); + + // return MenuBox; } //----------------------------------------------------------------------------- @@ -613,29 +607,29 @@ HMENU MakeMainWindowMenus(void) //----------------------------------------------------------------------------- void RefreshScrollbars(void) { - SCROLLINFO vert, horiz; - SetUpScrollbars(&NeedHoriz, &horiz, &vert); - SetScrollInfo(HorizScrollBar, SB_CTL, &horiz, TRUE); - SetScrollInfo(VertScrollBar, SB_CTL, &vert, TRUE); - - RECT main; - GetClientRect(MainWindow, &main); - - if(NeedHoriz) { - MoveWindow(HorizScrollBar, 0, IoListTop - ScrollHeight - 2, - main.right - ScrollWidth - 2, ScrollHeight, TRUE); - ShowWindow(HorizScrollBar, SW_SHOW); - EnableWindow(HorizScrollBar, TRUE); - } else { - ShowWindow(HorizScrollBar, SW_HIDE); - } - MoveWindow(VertScrollBar, main.right - ScrollWidth - 2, 1, ScrollWidth, - NeedHoriz ? (IoListTop - ScrollHeight - 4) : (IoListTop - 3), TRUE); - - MoveWindow(VertScrollBar, main.right - ScrollWidth - 2, 1, ScrollWidth, - NeedHoriz ? (IoListTop - ScrollHeight - 4) : (IoListTop - 3), TRUE); - - InvalidateRect(MainWindow, NULL, FALSE); + // SCROLLINFO vert, horiz; + // SetUpScrollbars(&NeedHoriz, &horiz, &vert); + // SetScrollInfo(HorizScrollBar, SB_CTL, &horiz, TRUE); + // SetScrollInfo(VertScrollBar, SB_CTL, &vert, TRUE); + + // RECT main; + // GetClientRect(MainWindow, &main); + + // if(NeedHoriz) { + // MoveWindow(HorizScrollBar, 0, IoListTop - ScrollHeight - 2, + // main.right - ScrollWidth - 2, ScrollHeight, TRUE); + // ShowWindow(HorizScrollBar, SW_SHOW); + // EnableWindow(HorizScrollBar, TRUE); + // } else { + // ShowWindow(HorizScrollBar, SW_HIDE); + // } + // MoveWindow(VertScrollBar, main.right - ScrollWidth - 2, 1, ScrollWidth, + // NeedHoriz ? (IoListTop - ScrollHeight - 4) : (IoListTop - 3), TRUE); + + // MoveWindow(VertScrollBar, main.right - ScrollWidth - 2, 1, ScrollWidth, + // NeedHoriz ? (IoListTop - ScrollHeight - 4) : (IoListTop - 3), TRUE); + + // InvalidateRect(MainWindow, NULL, FALSE); } //----------------------------------------------------------------------------- @@ -644,44 +638,44 @@ void RefreshScrollbars(void) //----------------------------------------------------------------------------- void VscrollProc(WPARAM wParam) { - int prevY = ScrollYOffset; - switch(LOWORD(wParam)) { - case SB_LINEUP: - case SB_PAGEUP: - if(ScrollYOffset > 0) { - ScrollYOffset--; - } - break; - - case SB_LINEDOWN: - case SB_PAGEDOWN: - if(ScrollYOffset < ScrollYOffsetMax) { - ScrollYOffset++; - } - break; - - case SB_TOP: - ScrollYOffset = 0; - break; - - case SB_BOTTOM: - ScrollYOffset = ScrollYOffsetMax; - break; - - case SB_THUMBTRACK: - case SB_THUMBPOSITION: - ScrollYOffset = HIWORD(wParam); - break; - } - if(prevY != ScrollYOffset) { - SCROLLINFO si; - si.cbSize = sizeof(si); - si.fMask = SIF_POS; - si.nPos = ScrollYOffset; - SetScrollInfo(VertScrollBar, SB_CTL, &si, TRUE); - - InvalidateRect(MainWindow, NULL, FALSE); - } + // int prevY = ScrollYOffset; + // switch(LOWORD(wParam)) { + // case SB_LINEUP: + // case SB_PAGEUP: + // if(ScrollYOffset > 0) { + // ScrollYOffset--; + // } + // break; + + // case SB_LINEDOWN: + // case SB_PAGEDOWN: + // if(ScrollYOffset < ScrollYOffsetMax) { + // ScrollYOffset++; + // } + // break; + + // case SB_TOP: + // ScrollYOffset = 0; + // break; + + // case SB_BOTTOM: + // ScrollYOffset = ScrollYOffsetMax; + // break; + + // case SB_THUMBTRACK: + // case SB_THUMBPOSITION: + // ScrollYOffset = HIWORD(wParam); + // break; + // } + // if(prevY != ScrollYOffset) { + // SCROLLINFO si; + // si.cbSize = sizeof(si); + // si.fMask = SIF_POS; + // si.nPos = ScrollYOffset; + // SetScrollInfo(VertScrollBar, SB_CTL, &si, TRUE); + + // InvalidateRect(MainWindow, NULL, FALSE); + // } } //----------------------------------------------------------------------------- @@ -690,50 +684,50 @@ void VscrollProc(WPARAM wParam) //----------------------------------------------------------------------------- void HscrollProc(WPARAM wParam) { - int prevX = ScrollXOffset; - switch(LOWORD(wParam)) { - case SB_LINEUP: - ScrollXOffset -= FONT_WIDTH; - break; - - case SB_PAGEUP: - ScrollXOffset -= POS_WIDTH*FONT_WIDTH; - break; - - case SB_LINEDOWN: - ScrollXOffset += FONT_WIDTH; - break; - - case SB_PAGEDOWN: - ScrollXOffset += POS_WIDTH*FONT_WIDTH; - break; - - case SB_TOP: - ScrollXOffset = 0; - break; - - case SB_BOTTOM: - ScrollXOffset = ScrollXOffsetMax; - break; - - case SB_THUMBTRACK: - case SB_THUMBPOSITION: - ScrollXOffset = HIWORD(wParam); - break; - } - - if(ScrollXOffset > ScrollXOffsetMax) ScrollXOffset = ScrollXOffsetMax; - if(ScrollXOffset < 0) ScrollXOffset = 0; - - if(prevX != ScrollXOffset) { - SCROLLINFO si; - si.cbSize = sizeof(si); - si.fMask = SIF_POS; - si.nPos = ScrollXOffset; - SetScrollInfo(HorizScrollBar, SB_CTL, &si, TRUE); - - InvalidateRect(MainWindow, NULL, FALSE); - } + // int prevX = ScrollXOffset; + // switch(LOWORD(wParam)) { + // case SB_LINEUP: + // ScrollXOffset -= FONT_WIDTH; + // break; + + // case SB_PAGEUP: + // ScrollXOffset -= POS_WIDTH*FONT_WIDTH; + // break; + + // case SB_LINEDOWN: + // ScrollXOffset += FONT_WIDTH; + // break; + + // case SB_PAGEDOWN: + // ScrollXOffset += POS_WIDTH*FONT_WIDTH; + // break; + + // case SB_TOP: + // ScrollXOffset = 0; + // break; + + // case SB_BOTTOM: + // ScrollXOffset = ScrollXOffsetMax; + // break; + + // case SB_THUMBTRACK: + // case SB_THUMBPOSITION: + // ScrollXOffset = HIWORD(wParam); + // break; + // } + + // if(ScrollXOffset > ScrollXOffsetMax) ScrollXOffset = ScrollXOffsetMax; + // if(ScrollXOffset < 0) ScrollXOffset = 0; + + // if(prevX != ScrollXOffset) { + // SCROLLINFO si; + // si.cbSize = sizeof(si); + // si.fMask = SIF_POS; + // si.nPos = ScrollXOffset; + // SetScrollInfo(HorizScrollBar, SB_CTL, &si, TRUE); + + // InvalidateRect(MainWindow, NULL, FALSE); + // } } //----------------------------------------------------------------------------- @@ -744,72 +738,72 @@ void HscrollProc(WPARAM wParam) //----------------------------------------------------------------------------- void RefreshControlsToSettings(void) { - int i; - - if(!IoListOutOfSync) { - IoListSelectionPoint = -1; - for(i = 0; i < Prog.io.count; i++) { - if(ListView_GetItemState(IoList, i, LVIS_SELECTED)) { - IoListSelectionPoint = i; - break; - } - } - } - - ListView_DeleteAllItems(IoList); - for(i = 0; i < Prog.io.count; i++) { - LVITEM lvi; - lvi.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE; - lvi.state = lvi.stateMask = 0; - lvi.iItem = i; - lvi.iSubItem = 0; - lvi.pszText = LPSTR_TEXTCALLBACK; - lvi.lParam = i; - - if(ListView_InsertItem(IoList, &lvi) < 0) oops(); - } - if(IoListSelectionPoint >= 0) { - for(i = 0; i < Prog.io.count; i++) { - ListView_SetItemState(IoList, i, 0, LVIS_SELECTED); - } - ListView_SetItemState(IoList, IoListSelectionPoint, LVIS_SELECTED, - LVIS_SELECTED); - ListView_EnsureVisible(IoList, IoListSelectionPoint, FALSE); - } - IoListOutOfSync = FALSE; - - if(Prog.mcu) { - SendMessage(StatusBar, SB_SETTEXT, 0, (LPARAM)Prog.mcu->mcuName); - } else { - SendMessage(StatusBar, SB_SETTEXT, 0, (LPARAM)_("no MCU selected")); - } - char buf[256]; - sprintf(buf, _("cycle time %.2f ms"), (double)Prog.cycleTime/1000.0); - SendMessage(StatusBar, SB_SETTEXT, 1, (LPARAM)buf); - - if(Prog.mcu && (Prog.mcu->whichIsa == ISA_ANSIC || - Prog.mcu->whichIsa == ISA_INTERPRETED)) - { - strcpy(buf, ""); - } else { - sprintf(buf, _("processor clock %.4f MHz"), - (double)Prog.mcuClock/1000000.0); - } - SendMessage(StatusBar, SB_SETTEXT, 2, (LPARAM)buf); - - for(i = 0; i < NUM_SUPPORTED_MCUS; i++) { - if(&SupportedMcus[i] == Prog.mcu) { - CheckMenuItem(ProcessorMenu, MNU_PROCESSOR_0+i, MF_CHECKED); - } else { - CheckMenuItem(ProcessorMenu, MNU_PROCESSOR_0+i, MF_UNCHECKED); - } - } - // `(no microcontroller)' setting - if(!Prog.mcu) { - CheckMenuItem(ProcessorMenu, MNU_PROCESSOR_0+i, MF_CHECKED); - } else { - CheckMenuItem(ProcessorMenu, MNU_PROCESSOR_0+i, MF_UNCHECKED); - } + // int i; + + // if(!IoListOutOfSync) { + // IoListSelectionPoint = -1; + // for(i = 0; i < Prog.io.count; i++) { + // if(ListView_GetItemState(IoList, i, LVIS_SELECTED)) { + // IoListSelectionPoint = i; + // break; + // } + // } + // } + + // ListView_DeleteAllItems(IoList); + // for(i = 0; i < Prog.io.count; i++) { + // LVITEM lvi; + // lvi.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE; + // lvi.state = lvi.stateMask = 0; + // lvi.iItem = i; + // lvi.iSubItem = 0; + // lvi.pszText = LPSTR_TEXTCALLBACK; + // lvi.lParam = i; + + // if(ListView_InsertItem(IoList, &lvi) < 0) oops(); + // } + // if(IoListSelectionPoint >= 0) { + // for(i = 0; i < Prog.io.count; i++) { + // ListView_SetItemState(IoList, i, 0, LVIS_SELECTED); + // } + // ListView_SetItemState(IoList, IoListSelectionPoint, LVIS_SELECTED, + // LVIS_SELECTED); + // ListView_EnsureVisible(IoList, IoListSelectionPoint, FALSE); + // } + // IoListOutOfSync = FALSE; + + // if(Prog.mcu) { + // SendMessage(StatusBar, SB_SETTEXT, 0, (LPARAM)Prog.mcu->mcuName); + // } else { + // SendMessage(StatusBar, SB_SETTEXT, 0, (LPARAM)_("no MCU selected")); + // } + // char buf[256]; + // sprintf(buf, _("cycle time %.2f ms"), (double)Prog.cycleTime/1000.0); + // SendMessage(StatusBar, SB_SETTEXT, 1, (LPARAM)buf); + + // if(Prog.mcu && (Prog.mcu->whichIsa == ISA_ANSIC || + // Prog.mcu->whichIsa == ISA_INTERPRETED)) + // { + // strcpy(buf, ""); + // } else { + // sprintf(buf, _("processor clock %.4f MHz"), + // (double)Prog.mcuClock/1000000.0); + // } + // SendMessage(StatusBar, SB_SETTEXT, 2, (LPARAM)buf); + + // for(i = 0; i < NUM_SUPPORTED_MCUS; i++) { + // if(&SupportedMcus[i] == Prog.mcu) { + // CheckMenuItem(ProcessorMenu, MNU_PROCESSOR_0+i, MF_CHECKED); + // } else { + // CheckMenuItem(ProcessorMenu, MNU_PROCESSOR_0+i, MF_UNCHECKED); + // } + // } + // // `(no microcontroller)' setting + // if(!Prog.mcu) { + // CheckMenuItem(ProcessorMenu, MNU_PROCESSOR_0+i, MF_CHECKED); + // } else { + // CheckMenuItem(ProcessorMenu, MNU_PROCESSOR_0+i, MF_UNCHECKED); + // } } //----------------------------------------------------------------------------- @@ -818,24 +812,24 @@ void RefreshControlsToSettings(void) //----------------------------------------------------------------------------- void GenerateIoListDontLoseSelection(void) { - int i; - GtkTreeIter* iter; - GtkTreeModel **IoListPtr = (GtkTreeModel**)GTK_TREE_MODEL (IoList); - gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(view)), - GTK_SELECTION_SINGLE); - IoListSelectionPoint = -1; - for(i = 0; i < Prog.io.count; i++) { - if(gtk_tree_selection_get_selected (gtk_tree_view_get_selection(GTK_TREE_VIEW(view)), - IoListPtr, iter)) { - IoListSelectionPoint = i; - break; - } - } - IoListSelectionPoint = GenerateIoList(IoListSelectionPoint); - // can't just update the listview index; if I/O has been added then the - // new selection point might be out of range till we refill it - IoListOutOfSync = TRUE; - RefreshControlsToSettings(); + // int i; + // GtkTreeIter* iter; + // GtkTreeModel **IoListPtr = (GtkTreeModel**)GTK_TREE_MODEL (IoList); + // gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(view)), + // GTK_SELECTION_SINGLE); + // IoListSelectionPoint = -1; + // for(i = 0; i < Prog.io.count; i++) { + // if(gtk_tree_selection_get_selected (gtk_tree_view_get_selection(GTK_TREE_VIEW(view)), + // IoListPtr, iter)) { + // IoListSelectionPoint = i; + // break; + // } + // } + // IoListSelectionPoint = GenerateIoList(IoListSelectionPoint); + // // can't just update the listview index; if I/O has been added then the + // // new selection point might be out of range till we refill it + // IoListOutOfSync = TRUE; + // RefreshControlsToSettings(); } //----------------------------------------------------------------------------- @@ -844,32 +838,32 @@ void GenerateIoListDontLoseSelection(void) //----------------------------------------------------------------------------- void MainWindowResized(void) { - RECT main; - GetClientRect(MainWindow, &main); - - RECT status; - GetWindowRect(StatusBar, &status); - int statusHeight = status.bottom - status.top; - - MoveWindow(StatusBar, 0, main.bottom - statusHeight, main.right, - statusHeight, TRUE); - - // Make sure that the I/O list can't disappear entirely. - if(IoListHeight < 30) { - IoListHeight = 30; - } - IoListTop = main.bottom - IoListHeight - statusHeight; - // Make sure that we can't drag the top of the I/O list above the - // bottom of the menu bar, because it then becomes inaccessible. - if(IoListTop < 5) { - IoListHeight = main.bottom - statusHeight - 5; - IoListTop = main.bottom - IoListHeight - statusHeight; - } - MoveWindow(IoList, 0, IoListTop, main.right, IoListHeight, TRUE); - - RefreshScrollbars(); - - InvalidateRect(MainWindow, NULL, FALSE); + // RECT main; + // GetClientRect(MainWindow, &main); + + // RECT status; + // GetWindowRect(StatusBar, &status); + // int statusHeight = status.bottom - status.top; + + // MoveWindow(StatusBar, 0, main.bottom - statusHeight, main.right, + // statusHeight, TRUE); + + // // Make sure that the I/O list can't disappear entirely. + // if(IoListHeight < 30) { + // IoListHeight = 30; + // } + // IoListTop = main.bottom - IoListHeight - statusHeight; + // // Make sure that we can't drag the top of the I/O list above the + // // bottom of the menu bar, because it then becomes inaccessible. + // if(IoListTop < 5) { + // IoListHeight = main.bottom - statusHeight - 5; + // IoListTop = main.bottom - IoListHeight - statusHeight; + // } + // MoveWindow(IoList, 0, IoListTop, main.right, IoListHeight, TRUE); + + // RefreshScrollbars(); + + // InvalidateRect(MainWindow, NULL, FALSE); } //----------------------------------------------------------------------------- @@ -878,62 +872,62 @@ void MainWindowResized(void) //----------------------------------------------------------------------------- void ToggleSimulationMode(void) { - InSimulationMode = !InSimulationMode; - - if(InSimulationMode) { - EnableMenuItem(SimulateMenu, MNU_START_SIMULATION, MF_ENABLED); - EnableMenuItem(SimulateMenu, MNU_SINGLE_CYCLE, MF_ENABLED); - - EnableMenuItem(FileMenu, MNU_OPEN, MF_GRAYED); - EnableMenuItem(FileMenu, MNU_SAVE, MF_GRAYED); - EnableMenuItem(FileMenu, MNU_SAVE_AS, MF_GRAYED); - EnableMenuItem(FileMenu, MNU_NEW, MF_GRAYED); - EnableMenuItem(FileMenu, MNU_EXPORT, MF_GRAYED); - - EnableMenuItem(TopMenu, 1, MF_GRAYED | MF_BYPOSITION); - EnableMenuItem(TopMenu, 2, MF_GRAYED | MF_BYPOSITION); - EnableMenuItem(TopMenu, 3, MF_GRAYED | MF_BYPOSITION); - EnableMenuItem(TopMenu, 5, MF_GRAYED | MF_BYPOSITION); + // InSimulationMode = !InSimulationMode; + + // if(InSimulationMode) { + // EnableMenuItem(SimulateMenu, MNU_START_SIMULATION, MF_ENABLED); + // EnableMenuItem(SimulateMenu, MNU_SINGLE_CYCLE, MF_ENABLED); + + // EnableMenuItem(FileMenu, MNU_OPEN, MF_GRAYED); + // EnableMenuItem(FileMenu, MNU_SAVE, MF_GRAYED); + // EnableMenuItem(FileMenu, MNU_SAVE_AS, MF_GRAYED); + // EnableMenuItem(FileMenu, MNU_NEW, MF_GRAYED); + // EnableMenuItem(FileMenu, MNU_EXPORT, MF_GRAYED); + + // EnableMenuItem(TopMenu, 1, MF_GRAYED | MF_BYPOSITION); + // EnableMenuItem(TopMenu, 2, MF_GRAYED | MF_BYPOSITION); + // EnableMenuItem(TopMenu, 3, MF_GRAYED | MF_BYPOSITION); + // EnableMenuItem(TopMenu, 5, MF_GRAYED | MF_BYPOSITION); - CheckMenuItem(SimulateMenu, MNU_SIMULATION_MODE, MF_CHECKED); - - ClearSimulationData(); - // Recheck InSimulationMode, because there could have been a compile - // error, which would have kicked us out of simulation mode. - if(UartFunctionUsed() && InSimulationMode) { - ShowUartSimulationWindow(); - } - } else { - RealTimeSimulationRunning = FALSE; - KillTimer(MainWindow, TIMER_SIMULATE); - - EnableMenuItem(SimulateMenu, MNU_START_SIMULATION, MF_GRAYED); - EnableMenuItem(SimulateMenu, MNU_STOP_SIMULATION, MF_GRAYED); - EnableMenuItem(SimulateMenu, MNU_SINGLE_CYCLE, MF_GRAYED); - - EnableMenuItem(FileMenu, MNU_OPEN, MF_ENABLED); - EnableMenuItem(FileMenu, MNU_SAVE, MF_ENABLED); - EnableMenuItem(FileMenu, MNU_SAVE_AS, MF_ENABLED); - EnableMenuItem(FileMenu, MNU_NEW, MF_ENABLED); - EnableMenuItem(FileMenu, MNU_EXPORT, MF_ENABLED); - - EnableMenuItem(TopMenu, 1, MF_ENABLED | MF_BYPOSITION); - EnableMenuItem(TopMenu, 2, MF_ENABLED | MF_BYPOSITION); - EnableMenuItem(TopMenu, 3, MF_ENABLED | MF_BYPOSITION); - EnableMenuItem(TopMenu, 5, MF_ENABLED | MF_BYPOSITION); - - CheckMenuItem(SimulateMenu, MNU_SIMULATION_MODE, MF_UNCHECKED); - - if(UartFunctionUsed()) { - DestroyUartSimulationWindow(); - } - } - - UpdateMainWindowTitleBar(); - - DrawMenuBar(MainWindow); - InvalidateRect(MainWindow, NULL, FALSE); - ListView_RedrawItems(IoList, 0, Prog.io.count - 1); + // CheckMenuItem(SimulateMenu, MNU_SIMULATION_MODE, MF_CHECKED); + + // ClearSimulationData(); + // // Recheck InSimulationMode, because there could have been a compile + // // error, which would have kicked us out of simulation mode. + // if(UartFunctionUsed() && InSimulationMode) { + // ShowUartSimulationWindow(); + // } + // } else { + // RealTimeSimulationRunning = FALSE; + // KillTimer(MainWindow, TIMER_SIMULATE); + + // EnableMenuItem(SimulateMenu, MNU_START_SIMULATION, MF_GRAYED); + // EnableMenuItem(SimulateMenu, MNU_STOP_SIMULATION, MF_GRAYED); + // EnableMenuItem(SimulateMenu, MNU_SINGLE_CYCLE, MF_GRAYED); + + // EnableMenuItem(FileMenu, MNU_OPEN, MF_ENABLED); + // EnableMenuItem(FileMenu, MNU_SAVE, MF_ENABLED); + // EnableMenuItem(FileMenu, MNU_SAVE_AS, MF_ENABLED); + // EnableMenuItem(FileMenu, MNU_NEW, MF_ENABLED); + // EnableMenuItem(FileMenu, MNU_EXPORT, MF_ENABLED); + + // EnableMenuItem(TopMenu, 1, MF_ENABLED | MF_BYPOSITION); + // EnableMenuItem(TopMenu, 2, MF_ENABLED | MF_BYPOSITION); + // EnableMenuItem(TopMenu, 3, MF_ENABLED | MF_BYPOSITION); + // EnableMenuItem(TopMenu, 5, MF_ENABLED | MF_BYPOSITION); + + // CheckMenuItem(SimulateMenu, MNU_SIMULATION_MODE, MF_UNCHECKED); + + // if(UartFunctionUsed()) { + // DestroyUartSimulationWindow(); + // } + // } + + // UpdateMainWindowTitleBar(); + + // DrawMenuBar(MainWindow); + // InvalidateRect(MainWindow, NULL, FALSE); + // ListView_RedrawItems(IoList, 0, Prog.io.count - 1); } //----------------------------------------------------------------------------- @@ -942,11 +936,11 @@ void ToggleSimulationMode(void) //----------------------------------------------------------------------------- void StartSimulation(void) { - RealTimeSimulationRunning = TRUE; - EnableMenuItem(SimulateMenu, MNU_START_SIMULATION, MF_GRAYED); - EnableMenuItem(SimulateMenu, MNU_STOP_SIMULATION, MF_ENABLED); - StartSimulationTimer(); - UpdateMainWindowTitleBar(); + // RealTimeSimulationRunning = TRUE; + // EnableMenuItem(SimulateMenu, MNU_START_SIMULATION, MF_GRAYED); + // EnableMenuItem(SimulateMenu, MNU_STOP_SIMULATION, MF_ENABLED); + // StartSimulationTimer(); + // UpdateMainWindowTitleBar(); } //----------------------------------------------------------------------------- @@ -955,11 +949,11 @@ void StartSimulation(void) //----------------------------------------------------------------------------- void StopSimulation(void) { - RealTimeSimulationRunning = FALSE; + // RealTimeSimulationRunning = FALSE; - EnableMenuItem(SimulateMenu, MNU_START_SIMULATION, MF_ENABLED); - EnableMenuItem(SimulateMenu, MNU_STOP_SIMULATION, MF_GRAYED); - KillTimer(MainWindow, TIMER_SIMULATE); + // EnableMenuItem(SimulateMenu, MNU_START_SIMULATION, MF_ENABLED); + // EnableMenuItem(SimulateMenu, MNU_STOP_SIMULATION, MF_GRAYED); + // KillTimer(MainWindow, TIMER_SIMULATE); - UpdateMainWindowTitleBar(); + // UpdateMainWindowTitleBar(); } diff --git a/ldmicro/miscutil.cpp b/ldmicro/miscutil.cpp index 428e5f6..4fddcf4 100644 --- a/ldmicro/miscutil.cpp +++ b/ldmicro/miscutil.cpp @@ -20,7 +20,7 @@ // Miscellaneous utility functions that don't fit anywhere else. IHEX writing, // verified memory allocator, other junk. //----------------------------------------------------------------------------- -#include <windows.h> +#include "linuxUI.h" #include <stdio.h> #include <stdlib.h> @@ -65,19 +65,19 @@ void dbp(char *str, ...) //----------------------------------------------------------------------------- #define ATTACH_PARENT_PROCESS ((DWORD)-1) // defined in WinCon.h, but only if // _WIN32_WINNT >= 0x500 -BOOL AttachConsoleDynamic(DWORD base) -{ - typedef BOOL WINAPI fptr_acd(DWORD base); - fptr_acd *fp; +// BOOL AttachConsoleDynamic(DWORD base) +// { +// typedef BOOL WINAPI fptr_acd(DWORD base); +// fptr_acd *fp; - HMODULE hm = LoadLibrary("kernel32.dll"); - if(!hm) return FALSE; +// HMODULE hm = LoadLibrary("kernel32.dll"); +// if(!hm) return FALSE; - fp = (fptr_acd *)GetProcAddress(hm, "AttachConsole"); - if(!fp) return FALSE; +// fp = (fptr_acd *)GetProcAddress(hm, "AttachConsole"); +// if(!fp) return FALSE; - return fp(base); -} +// return fp(base); +// } //----------------------------------------------------------------------------- // For error messages to the user; printf-like, to a message box. @@ -88,20 +88,19 @@ void Error(char *str, ...) char buf[1024]; va_start(f, str); vsprintf(buf, str, f); + va_end(f); if(RunningInBatchMode) { + printf("print batch mode"); /* Only required for windows * AttachConsoleDynamic(ATTACH_PARENT_PROCESS); */ // Indicate that it's an error, plus the output filename - printf("compile error ('%s'): ", CurrentCompileFile); - // The error message itself - printf(buf); - // And an extra newline to be safe. - strcpy(str, "\n"); - printf(str); + printf("compile error ('%s'): \n", CurrentCompileFile); + // The error message itself and an extra newline to be safe. + printf("%s\n", buf); } else { - HWND h = GetForegroundWindow(); - MessageBox(h, buf, _("LDmicro Error"), MB_OK | MB_ICONERROR); + //HWND h = GetForegroundWindow(); + //MessageBox(h, buf, _("LDmicro Error"), MB_OK | MB_ICONERROR); } } @@ -113,12 +112,12 @@ void CompileSuccessfulMessage(char *str) { if(RunningInBatchMode) { char str[MAX_PATH+100]; - sprintf(str, "compiled okay, wrote '%s'\n", CurrentCompileFile); + printf("compiled okay, wrote '%s'\n", CurrentCompileFile); - AttachConsoleDynamic(ATTACH_PARENT_PROCESS); - HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE); - DWORD written; - WriteFile(h, str, strlen(str), &written, NULL); + //AttachConsoleDynamic(ATTACH_PARENT_PROCESS); + //HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE); + //DWORD written; + //riteFile(h, str, strlen(str), &written, NULL); } else { MessageBox(MainWindow, str, _("Compile Successful"), MB_OK | MB_ICONINFORMATION); @@ -146,11 +145,11 @@ void CheckHeap(char *file, int line) SkippedCalls = 0; LastCallTime = now; - if(!HeapValidate(MainHeap, 0, NULL)) { - dbp("file %s line %d", file, line); - Error("Noticed memory corruption at file '%s' line %d.", file, line); - oops(); - } + // if(!HeapValidate(MainHeap, 0, NULL)) { + // dbp("file %s line %d", file, line); + // Error("Noticed memory corruption at file '%s' line %d.", file, line); + // oops(); + // } } //----------------------------------------------------------------------------- @@ -207,17 +206,17 @@ HWND CreateWindowClient(DWORD exStyle, char *className, char *windowName, DWORD style, int x, int y, int width, int height, HWND parent, HMENU menu, HINSTANCE instance, void *param) { - HWND h = CreateWindowEx(exStyle, className, windowName, style, x, y, - width, height, parent, menu, instance, param); + // HWND h = CreateWindowEx(exStyle, className, windowName, style, x, y, + // width, height, parent, menu, instance, param); - RECT r; - GetClientRect(h, &r); - width = width - (r.right - width); - height = height - (r.bottom - height); + // RECT r; + // GetClientRect(h, &r); + // width = width - (r.right - width); + // height = height - (r.bottom - height); - SetWindowPos(h, HWND_TOP, x, y, width, height, 0); + // SetWindowPos(h, HWND_TOP, x, y, width, height, 0); - return h; + return NULL; } //----------------------------------------------------------------------------- @@ -227,30 +226,30 @@ HWND CreateWindowClient(DWORD exStyle, char *className, char *windowName, static LRESULT CALLBACK DialogProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { - switch (msg) { - case WM_NOTIFY: - break; - - case WM_COMMAND: { - HWND h = (HWND)lParam; - if(h == OkButton && wParam == BN_CLICKED) { - DialogDone = TRUE; - } else if(h == CancelButton && wParam == BN_CLICKED) { - DialogDone = TRUE; - DialogCancel = TRUE; - } - break; - } - - case WM_CLOSE: - case WM_DESTROY: - DialogDone = TRUE; - DialogCancel = TRUE; - break; - - default: - return DefWindowProc(hwnd, msg, wParam, lParam); - } + // switch (msg) { + // case WM_NOTIFY: + // break; + + // case WM_COMMAND: { + // HWND h = (HWND)lParam; + // if(h == OkButton && wParam == BN_CLICKED) { + // DialogDone = TRUE; + // } else if(h == CancelButton && wParam == BN_CLICKED) { + // DialogDone = TRUE; + // DialogCancel = TRUE; + // } + // break; + // } + + // case WM_CLOSE: + // case WM_DESTROY: + // DialogDone = TRUE; + // DialogCancel = TRUE; + // break; + + // default: + // return DefWindowProc(hwnd, msg, wParam, lParam); + // } return 1; } @@ -262,7 +261,7 @@ static LRESULT CALLBACK DialogProc(HWND hwnd, UINT msg, WPARAM wParam, //----------------------------------------------------------------------------- void NiceFont(HWND h) { - SendMessage(h, WM_SETFONT, (WPARAM)MyNiceFont, TRUE); +// SendMessage(h, WM_SETFONT, (WPARAM)MyNiceFont, TRUE); } //----------------------------------------------------------------------------- @@ -271,7 +270,7 @@ void NiceFont(HWND h) //----------------------------------------------------------------------------- void FixedFont(HWND h) { - SendMessage(h, WM_SETFONT, (WPARAM)MyFixedFont, TRUE); + // SendMessage(h, WM_SETFONT, (WPARAM)MyFixedFont, TRUE); } //----------------------------------------------------------------------------- @@ -279,36 +278,36 @@ void FixedFont(HWND h) //----------------------------------------------------------------------------- void MakeDialogBoxClass(void) { - WNDCLASSEX wc; - memset(&wc, 0, sizeof(wc)); - wc.cbSize = sizeof(wc); - - wc.style = CS_BYTEALIGNCLIENT | CS_BYTEALIGNWINDOW | CS_OWNDC | - CS_DBLCLKS; - wc.lpfnWndProc = (WNDPROC)DialogProc; - wc.hInstance = Instance; - wc.hbrBackground = (HBRUSH)COLOR_BTNSHADOW; - wc.lpszClassName = "LDmicroDialog"; - wc.lpszMenuName = NULL; - wc.hCursor = LoadCursor(NULL, IDC_ARROW); - wc.hIcon = (HICON)LoadImage(Instance, MAKEINTRESOURCE(4000), - IMAGE_ICON, 32, 32, 0); - wc.hIconSm = (HICON)LoadImage(Instance, MAKEINTRESOURCE(4000), - IMAGE_ICON, 16, 16, 0); - - RegisterClassEx(&wc); - - MyNiceFont = CreateFont(16, 0, 0, 0, FW_REGULAR, FALSE, FALSE, FALSE, - ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, - FF_DONTCARE, "Tahoma"); - if(!MyNiceFont) - MyNiceFont = (HFONT)GetStockObject(SYSTEM_FONT); - - MyFixedFont = CreateFont(14, 0, 0, 0, FW_REGULAR, FALSE, FALSE, FALSE, - ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, - FF_DONTCARE, "Lucida Console"); - if(!MyFixedFont) - MyFixedFont = (HFONT)GetStockObject(SYSTEM_FONT); + // WNDCLASSEX wc; + // memset(&wc, 0, sizeof(wc)); + // wc.cbSize = sizeof(wc); + + // wc.style = CS_BYTEALIGNCLIENT | CS_BYTEALIGNWINDOW | CS_OWNDC | + // CS_DBLCLKS; + // wc.lpfnWndProc = (WNDPROC)DialogProc; + // wc.hInstance = Instance; + // wc.hbrBackground = (HBRUSH)COLOR_BTNSHADOW; + // wc.lpszClassName = "LDmicroDialog"; + // wc.lpszMenuName = NULL; + // wc.hCursor = LoadCursor(NULL, IDC_ARROW); + // wc.hIcon = (HICON)LoadImage(Instance, MAKEINTRESOURCE(4000), + // IMAGE_ICON, 32, 32, 0); + // wc.hIconSm = (HICON)LoadImage(Instance, MAKEINTRESOURCE(4000), + // IMAGE_ICON, 16, 16, 0); + + // RegisterClassEx(&wc); + + // MyNiceFont = CreateFont(16, 0, 0, 0, FW_REGULAR, FALSE, FALSE, FALSE, + // ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, + // FF_DONTCARE, "Tahoma"); + // if(!MyNiceFont) + // MyNiceFont = (HFONT)GetStockObject(SYSTEM_FONT); + + // MyFixedFont = CreateFont(14, 0, 0, 0, FW_REGULAR, FALSE, FALSE, FALSE, + // ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, + // FF_DONTCARE, "Lucida Console"); + // if(!MyFixedFont) + // MyFixedFont = (HFONT)GetStockObject(SYSTEM_FONT); } //----------------------------------------------------------------------------- diff --git a/ldmicro/naminglist.cpp b/ldmicro/naminglist.cpp deleted file mode 100644 index 5c6f6ed..0000000 --- a/ldmicro/naminglist.cpp +++ /dev/null @@ -1,338 +0,0 @@ -#include <windows.h> -#include <commctrl.h> -#include <stdio.h> -#include <stdlib.h> -#include <wincodec.h> -#include <Windowsx.h> - -#include "ldmicro.h" -#include "naminglist.h" -#include "components\components.h" -#include "advanceddialog.h" - -LVITEM lvi; - -void ShowNameListDialog(); -double SaveNameListDialog(int PinId, int Index); -static BOOL DlgDone, DlgCancel; -static LRESULT CALLBACK SmplDlgProc(HWND hwnd, UINT msg, WPARAM wParam, - LPARAM lParam); - -int NameList_AddName(LPCTSTR Name, int PinId, int Index) -{ - lvi.mask = LVIF_TEXT | LVIF_PARAM | LVIF_STATE; - lvi.state = lvi.stateMask = 0; - lvi.iItem = Index; - lvi.iSubItem = 0; - lvi.pszText = (LPSTR)Name; - lvi.lParam = PinId; - return ListView_InsertItem(NamingList, &lvi); -} - -int NameList_AddVolt(LPCTSTR Name, int Index) -{ - ListView_SetItemText(NamingList, Index, 1 , (LPSTR)Name); - return 0; -} - -void PopulateNamingList() -{ - int ItmCount = Prog.io.count; - int i; - // ListView_DeleteAllItems(NamingList); - for(i=0; i<ItmCount; i++) - { - switch(Prog.io.assignment[i].type){ - - case IO_TYPE_DIG_INPUT: - case IO_TYPE_DIG_OUTPUT: - case IO_TYPE_READ_ADC: - case IO_TYPE_UART_TX: - case IO_TYPE_UART_RX: - case IO_TYPE_PWM_OUTPUT: - { - LPCTSTR Name = (LPCTSTR)Prog.io.assignment[i].name; - // MessageBox(NULL, - // Name, "Name", MB_OK | MB_ICONWARNING); - SetMcu(RegisterPinName(Name), Prog.io.assignment[i].type); - LVFINDINFO temp; - temp.psz = Name; - temp.flags = LVFI_STRING; - int index = ListView_FindItem(NamingList, -1, &temp); - /*char vx[3],vy[3]; - _itoa(10,vy,10); - _itoa(index,vx,10); - MessageBox(NULL, - _(vx), _(vy), MB_OK | MB_ICONWARNING);*/ - break; - } - default: - break; - } - } - /*char vx[3],vy[3]; - _itoa(NameCount,vy,10); - _itoa(ItmCount,vx,10); - MessageBox(NULL, - _(vx), _(vy), MB_OK | MB_ICONWARNING);*/ -} -void RefreshNamingList() -{ - UINT i=0; - ListView_DeleteAllItems(NamingList); - for(i=0; i<NameCount; i++) - { - /*char vx[3]; - _itoa(i,vx,10); - MessageBox(NULL, NameId[i].Name, (LPCTSTR)vx, MB_OK |MB_ICONWARNING);*/ - int NameIndex = NameList_AddName((LPCTSTR)NameId[i].Name, NameId[i].PinId, i); - int index = IsMCUPin(NameId[i].PinId); - if(index >=0) - { - if(McuPin[index].InternalPullup) - { - NameList_AddVolt((LPCTSTR)"Pullup", NameIndex); - NameId[i].PinData.Volt = VOLT_5; - } - else - { - NameList_AddVolt((LPCTSTR)"V_OPEN", NameIndex); - NameId[i].PinData.Volt = V_OPEN; - } - // MessageBox(NULL, (LPCTSTR)NameId[i].Name,"Test", MB_OK | MB_ICONWARNING); - } - else - { - char Voltage[15]; - sprintf((char*)Voltage,"%f", NameId[i].PinData.Volt); - NameList_AddVolt(LPCTSTR(Voltage), NameIndex); - /*char Debug[256]; - sprintf_s(Debug, "Nameid[%d].PinData.Volt = %f \t Index= %d\n", - i,NameId[i].PinData.Volt, NameIndex); - OutputDebugString(Debug);*/ - } - NameId[i].PinData.ProgVolt = NameId[i].PinData.Volt; - } -} - -void NamingListProc(NMHDR *h) -{ - switch(h->code) { - case LVN_ITEMACTIVATE: - { - if(!SimulationStarted) - { - int PinId; - // NMITEMACTIVATE *i = (NMITEMACTIVATE *)h; - LVITEM lvi; - lvi.mask = LVIF_PARAM; - lvi.iItem = ListView_GetNextItem(NamingList, -1, LVNI_SELECTED); - ListView_GetItem(NamingList, &lvi); - PinId = (int) lvi.lParam; - int index = IsMCUPin(PinId); - if(index >= 0) - { - ToggleInternalPullup(PinId); - McuPin[index].InternalPullup ? - NameList_AddVolt((LPCTSTR)"Pullup", lvi.iItem): - NameList_AddVolt((LPCTSTR)"V_OPEN", lvi.iItem); - // MessageBox(NULL, "Pullup","NamingListProc" , MB_OK | MB_ICONWARNING): - // MessageBox(NULL, "V_OPEN", "NamingListProc", MB_OK | MB_ICONWARNING); - /*char vx[3],vy[3]; - _itoa(PinId,vy,10); - _itoa(index,vx,10); - MessageBox(NULL, - "Selected", _(vx), MB_OK | MB_ICONWARNING);*/ - } - else - SaveNameListDialog(PinId,lvi.iItem); - // Set voltage for PinId if it is not mcupin - /*char vx[3],vy[3]; - _itoa(10,vy,10); - _itoa(PinId,vx,10); - MessageBox(NULL, - "Selected", _(vx), MB_OK | MB_ICONWARNING);*/ - } - break; - } - default: - break; - } -} - -void MakeSmplDialogClass(void) -{ - WNDCLASSEX wc; - memset(&wc, 0, sizeof(wc)); - wc.cbSize = sizeof(wc); - - wc.style = CS_BYTEALIGNCLIENT | CS_BYTEALIGNWINDOW | CS_OWNDC | - CS_DBLCLKS; - wc.lpfnWndProc = (WNDPROC)SmplDlgProc; - wc.hInstance = Instance; - wc.hbrBackground = (HBRUSH)COLOR_BTNSHADOW; - wc.lpszClassName = "SmplDialog"; - wc.lpszMenuName = NULL; - wc.hCursor = LoadCursor(NULL, IDC_SIZEWE); - wc.hIcon = (HICON)LoadImage(Instance, MAKEINTRESOURCE(4000), - IMAGE_ICON, 32, 32, 0); - wc.hIconSm = (HICON)LoadImage(Instance, MAKEINTRESOURCE(4000), - IMAGE_ICON, 16, 16, 0); - - RegisterClassEx(&wc); - - AdvNiceFont = CreateFont(16, 0, 0, 0, FW_REGULAR, FALSE, FALSE, FALSE, - ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, - FF_DONTCARE, "Tahoma"); - if(!AdvNiceFont) - AdvNiceFont = (HFONT)GetStockObject(SYSTEM_FONT); - - AdvFixedFont = CreateFont(14, 0, 0, 0, FW_REGULAR, FALSE, FALSE, FALSE, - ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, - FF_DONTCARE, "Lucida Console"); - if(!AdvFixedFont) - AdvFixedFont = (HFONT)GetStockObject(SYSTEM_FONT); -} - -static LRESULT CALLBACK SmplDlgProc(HWND hwnd, UINT msg, WPARAM wParam, - LPARAM lParam) -{ - switch (msg) { - case WM_NOTIFY: - break; - - case WM_COMMAND: { - HWND h = (HWND)lParam; - if(h == OkButton && wParam == BN_CLICKED) { - DlgDone = TRUE; - } else if(h == CancelButton && wParam == BN_CLICKED) { - DlgDone = TRUE; - DlgCancel = TRUE; - } - break; - } - - case WM_CLOSE: - case WM_DESTROY: - DlgDone = TRUE; - DlgCancel = TRUE; - break; - - default: - return DefWindowProc(hwnd, msg, wParam, lParam); - } - - return 1; -} - -double SaveNameListDialog(int PinId, int Index) -{ - double volt; - for(UINT i=0;i<NameCount;i++) - { - if(NameId[i].PinId == PinId) - { - volt = NameId[i].PinData.Volt; - TCHAR Voltage[15]; - if(volt == (double)GND) - strcpy((char*)Voltage, "GND"); - else if(volt == (double)VOLT_5) - strcpy((char*)Voltage, "VOLT_5"); - else if(volt == (double)V_OPEN) - strcpy((char*)Voltage, "V_OPEN"); - else - sprintf((char*)Voltage,"%f",volt); - HWND NameVoltDialog = CreateWindowClient(0, "SmplDialog", - NameId[i].Name, WS_OVERLAPPED | WS_SYSMENU | WS_POPUP | WS_CAPTION, - 100, 100, 304, 15 + 30*2, NULL, NULL, Instance, NULL); - - HWND textLabel = CreateWindowEx(0, WC_STATIC, _("Volt:"), - WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SS_RIGHT, - 10, 20, 50, 21, NameVoltDialog, NULL, Instance, NULL); - NiceFont(textLabel); - - HWND ValueTextbox = CreateWindowEx(WS_EX_CLIENTEDGE, WC_EDIT, "", - WS_CHILD | ES_AUTOHSCROLL | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE, - 65, 20, 115, 21, NameVoltDialog, NULL, Instance, NULL); - FixedFont(ValueTextbox); - - OkButton = CreateWindowEx(0, WC_BUTTON, ("OK"), - WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE | BS_DEFPUSHBUTTON, - 220, 10, 70, 23, NameVoltDialog, NULL, NULL, NULL); - NiceFont(OkButton); - - CancelButton = CreateWindowEx(0, WC_BUTTON, ("Cancel"), - WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE, - 220, 40, 70, 23, NameVoltDialog, NULL, NULL, NULL); - FixedFont(CancelButton); - - Edit_SetText(ValueTextbox,Voltage); - EnableWindow(AdvancedDialog, FALSE); - EnableWindow(MainWindow, FALSE); - ShowWindow(NameVoltDialog, TRUE); - SetFocus(ValueTextbox); - SendMessage(ValueTextbox, EM_SETSEL, 0, -1); - - MSG msg; - DWORD ret; - DlgDone = FALSE; - DlgCancel = FALSE; - while((ret = GetMessage(&msg, NULL, 0, 0)) && !DlgDone) { - if(msg.message == WM_KEYDOWN) { - if(msg.wParam == VK_RETURN) { - DlgDone = TRUE; - break; - } else if(msg.wParam == VK_ESCAPE) { - DlgDone = TRUE; - DlgCancel = TRUE; - break; - } - } - - if(IsDialogMessage(NameVoltDialog, &msg)) continue; - TranslateMessage(&msg); - DispatchMessage(&msg); - } - - if(!DlgCancel) { - // Set Voltage here - Edit_GetText(ValueTextbox, Voltage, 15); - volt = atof(Voltage); - if(strcmp((char*)Voltage, "GND") == 0) - { - volt = GND; - } - else if(strcmp((char*)Voltage, "VOLT_5") == 0) - { - volt = 5; - } - else if(strcmp((char*)Voltage, "V_OPEN") == 0) - { - volt = V_OPEN; - } - else if(volt == 0.0f) - { - EnableWindow(AdvancedDialog, TRUE); - EnableWindow(MainWindow, TRUE); - DestroyWindow(NameVoltDialog); - volt = V_OPEN; - } - NameList_AddVolt((LPCTSTR)Voltage, Index); - NameList_SetVolt(i, volt); - } - NameId[i].PinData.Volt = volt; - NameId[i].PinData.ProgVolt = volt; - //CreateVoltRequest(i,volt); - EnableWindow(AdvancedDialog, TRUE); - EnableWindow(MainWindow, TRUE); - DestroyWindow(NameVoltDialog); - } - } - return volt; -} - -double NameList_SetVolt(int Index, double volt) -{ - NameId[Index].PinData.Volt = volt; - return volt; -} diff --git a/ldmicro/obj/helptext.cpp b/ldmicro/obj/helptext.cpp new file mode 100644 index 0000000..16d60fd --- /dev/null +++ b/ldmicro/obj/helptext.cpp @@ -0,0 +1,3877 @@ +// generated by txt2c.pl from
+#include <stdlib.h>
+#ifdef LDLANG_DE
+char *HelpTextDe[] = {
+ "",
+ "EINFÜHRUNG",
+ "===========",
+ "",
+ "LDmicro erzeugt einen systemspezifischen Code für einige Microchip PIC16",
+ "und Atmel AVR Mikroprozessoren. Üblicherweise wird die Software für diese",
+ "Prozessoren in Programmsprachen, wie Assembler, C oder BASIC geschrieben.",
+ "Ein Programm, welches in einer dieser Sprachen abgefasst ist, enthält",
+ "eine Anweisungsliste. Auch sind die diese Sprachen sehr leistungsfähig",
+ "und besonders gut geeignet für die Architektur dieser Prozessoren,",
+ "welche diese Anweisungsliste intern abarbeiten.",
+ "",
+ "Programme für speicherprogrammierbare Steuerungen (SPS) andererseits,",
+ "werden oftmals im Kontaktplan (KOP = ladder logic) geschrieben.",
+ "Ein einfaches Programm, könnte wie folgt aussehen:",
+ "",
+ " || ||",
+ " || Xbutton1 Tdon Rchatter Yred ||",
+ " 1 ||-------]/[---------[TON 1.000 s]-+-------]/[--------------( )-------||",
+ " || | ||",
+ " || Xbutton2 Tdof | ||",
+ " ||-------]/[---------[TOF 2.000 s]-+ ||",
+ " || ||",
+ " || ||",
+ " || ||",
+ " || Rchatter Ton Tneu Rchatter ||",
+ " 2 ||-------]/[---------[TON 1.000 s]----[TOF 1.000 s]---------( )-------||",
+ " || ||",
+ " || ||",
+ " || ||",
+ " ||------[END]---------------------------------------------------------||",
+ " || ||",
+ " || ||",
+ "",
+ " (TON ist eine Anzugsverzögerung, TOF eine Abfallverzögerung.",
+ " Die --] [-- Anweisungen bedeuten Eingänge, die sich ähnlich, wie Relais-",
+ " kontakte verhalten. Die --( )-- Anweisungen bedeuten Ausgänge, die sich",
+ " ähnlich, wie Relaisspulen verhalten. Viele gute Bezugsquellen werden für",
+ " KOP im Internet oder sonst wo angeboten; Einzelheiten zu dieser speziellen",
+ " Ausführung werden weiter unten angegeben.)",
+ "",
+ "Einige Unterschiede sind jedoch offensichtlich:",
+ "",
+ "* Das Programm wird in einem grafischen Format dargestellt",
+ " und nicht mit einer aus Anweisungen bestehenden Textliste. Viele",
+ " Anwender werden dies zunächst als besser verständlich auffassen.",
+ "",
+ "* Diese Programme erscheinen wie einfachste Schaltpläne, mit",
+ " Relaiskontakten (Eingängen) and Spulen (Ausgängen). Dies ist recht",
+ " intuitiv für Programmierer, die über Kenntnisse der Theorie von",
+ " Elektroschaltplänen verfügen.",
+ "",
+ "* Der ‘ladder logic compiler’ übernimmt was wo berechnet wird.",
+ " Es ist nicht notwendig einen Code zu schreiben, um zu errechnen, wann",
+ " der Status (Zustand) der Ausgänge neu bestimmt werden muss, z.B. auf",
+ " Grund einer Änderung eines Eingangs oder Timers. Auch braucht man die",
+ " Reihenfolge der Berechnungen nicht anzugeben; die SPS-Hilfsprogramme",
+ " übernehmen dies.",
+ "",
+ "LDmicro kompiliert ‘ladder logic’ (KOP) in PIC16- oder AVR-Code.",
+ "Die folgenden Prozessoren werden unterstützt:",
+ "",
+ " * PIC16F877",
+ " * PIC16F628",
+ " * PIC16F876 (ungetestet)",
+ " * PIC16F88 (ungetestet)",
+ " * PIC16F819 (ungetestet)",
+ " * PIC16F887 (ungetestet)",
+ " * PIC16F886 (ungetestet)",
+ " * ATmega8 (ungetestet)",
+ " * ATmega16 (ungetestet)",
+ " * ATmega32 (ungetestet)",
+ " * ATmega128",
+ " * ATmega64",
+ " * ATmega162 (ungetestet)",
+ "",
+ "Es wäre einfach noch weitere AVR- oder PIC16-Prozessoren zu unterstützen,",
+ "aber ich habe keine Möglichkeit diese zu testen. Falls Sie einen",
+ "bestimmten benötigen, so nehmen Sie Kontakt mit mir auf und ich werde",
+ "sehen, was ich tun kann.",
+ "",
+ "Mit LDmicro können Sie ein Kontaktplan-Programm zeichnen bzw. entwickeln.",
+ "Auch können Sie dies in Realzeit mit Ihrem Computer simulieren. Wenn",
+ "Sie dann überzeugt sind, dass Ihr Programm korrekt ist, so können",
+ "Sie die Pins, entsprechend dem Programm als Ein- oder Ausgänge, dem",
+ "Mikroprozessor zuweisen. Nach der Zuweisung der Pins können Sie den PIC-",
+ "oder AVR-Code für Ihr Programm kompilieren. Der Compiler erzeugt eine",
+ "Hex-Datei, mit dem Sie dann Ihren Mikroprozessor programmieren. Dies",
+ "ist mit jedem PIC/AVR-Programmer möglich.",
+ "",
+ "LDmicro wurde entworfen, um in etwa mit den meisten kommerziellen",
+ "SPS-Systemen ähnlich zu sein. Es gibt einige Ausnahmen und viele Dinge",
+ "sind ohnehin kein Standard in der Industrie. Lesen Sie aufmerksam die",
+ "Beschreibung jeder Anweisung, auch wenn Ihnen diese vertraut erscheint.",
+ "Dieses Dokument setzt ein Grundwissen an Kontaktplan-Programmierung",
+ "und der Struktur von SPS-Software voraus (wie: der Ausführungszyklus,",
+ "Eingänge lesen, rechnen und Ausgänge setzen).",
+ "",
+ "",
+ "WEITERE ZIELE",
+ "=============",
+ "",
+ "Es ist auch möglich einen ANSI C - Code zu erzeugen. Diesen können",
+ "Sie dann für jeden Prozessor verwenden, für den Sie einen C-Compiler",
+ "besitzen. Sie sind dann aber selbst verantwortlich, den Ablauf zu",
+ "bestimmen. Das heißt, LDmicro erzeugt nur ein Stammprogramm für einen",
+ "Funktions- SPS-Zyklus. Sie müssen den SPS-Zyklus bei jedem Durchlauf",
+ "aufrufen und auch die Ausführung (Implementierung) der E/A-Funktionen,",
+ "die der SPS-Zyklus abruft (wie: lesen/schreiben, digitaler Eingang usw.).",
+ "Für mehr Einzelheiten: Siehe die Kommentare in dem erzeugten Quellcode.",
+ "",
+ "Ganz zuletzt kann LDmicro auch für eine virtuelle Maschine einen",
+ "prozessor-unabhängigen Byte-Code erzeugen, welche mit der KOP-Kodierung",
+ "(ladder logic) laufen soll. Ich habe eine Beispiel-Anwendung des",
+ "VM/Interpreters vorgesehen, in ziemlich gutem C geschrieben. Dieses",
+ "Anwendungsziel wird halbwegs auf jeder Plattform funktionieren, so lange",
+ "Sie Ihre eigene VM vorsehen. Dies könnte für solche Anwendungen nützlich",
+ "sein, für die Sie KOP (ladder logic) als Datentransfer-Sprache verwenden",
+ "möchten, um ein größeres Programm anzupassen. Für weitere Einzelheiten:",
+ "Siehe die Kommentare in dem Beispiel-Interpreter.",
+ "",
+ "",
+ "OPTIONEN DER BEFEHLSZEILEN ",
+ "==========================",
+ "",
+ "ldmicro.exe läuft normalerweise ohne eine Befehlszeilen-Option.",
+ "Das heißt, dass Sie nur ein Tastenkürzel zu dem Programm benötigen",
+ "oder es auf dem Desktop abspeichern und dann auf das Symbol (die Ikone)",
+ "doppelklicken, um es laufen zu lassen. Danach können Sie alles ausführen,",
+ "was das GUI (Graphical User Interface) zulässt.",
+ "",
+ "Wenn man an LDmicro einen alleinstehenden Dateinamen in der Befehlszeile",
+ "vergeben hat (z. B. ‘ldmicro.exe asd.ld’), wird LDmicro versuchen ‘asd.ld’",
+ "zu öffnen, falls diese existiert. Dies bedeutet, dass man ldmicro.exe",
+ "mit .ld Dateien verbinden kann, sodass dies automatisch abläuft, wenn",
+ "man auf eine .ld Datei doppelklickt.",
+ "",
+ "Wenn man an LDmicro das Argument in der Befehlszeile in folgender Form",
+ "vergeben hat: ‘ldmicro.exe /c src.ld dest.hex’, so wird es versuchen",
+ "‘src.ld’ zu kompilieren und unter ‘dest.hex’ abzuspeichern. LDmicro endet",
+ "nach dem Kompilieren, unabhängig davon, ob die Kompilierung erfolgreich",
+ "war oder nicht. Alle Meldungen werden auf der Konsole ausgegeben. Dieser",
+ "Modus ist hilfreich, wenn man LDmicro von der Befehlszeile laufen",
+ "aus lässt.",
+ "",
+ "",
+ "GRUNDLAGEN",
+ "==========",
+ "",
+ "Wenn Sie LDmicro ohne Argumente aufrufen, so beginnt es als ein leeres",
+ "Programm. Wenn Sie LDmicro mit dem Namen eines ‘ladder’ (KOP)-Programms",
+ "(z.B. xxx.ld) in der Befehlszeile öffnen, dann wird es versuchen dieses",
+ "Programm am Anfang zu laden.",
+ "",
+ "LDmicro verwendet sein eigenes internes Format für das Programm und",
+ "man kann kein logisches Zeichen aus einem anderen (Fremd-)Programm",
+ "importieren.",
+ "",
+ "Falls Sie nicht ein schon vorhandenes Programm laden, dann wird Ihnen",
+ "ein Programm mit einem leeren Netzwerk geliefert. In dieses können Sie",
+ "einen Befehl einfügen; z. B. könnten Sie auch eine Reihe von Kontakten",
+ "einfügen (Anweisung -> Kontakte Einfügen), die zunächst mit ‘Xneu’",
+ "bezeichnet werden. ‘X’ bedeutet, dass der Kontakt auf einen Eingang",
+ "des Mikroprozessors festgelegt ist. Diesen Pin können Sie später zuweisen,",
+ "nachdem Sie den Mikroprozessor gewählt haben und die Kontakte",
+ "umbenannt haben. Der erste Buchstabe zeigt an, um welche Art Objekt es",
+ "sich handelt. Zum Beispiel:",
+ "",
+ " * XName -- Auf einen Eingang des Mikroprozessors festgelegt",
+ " * YName -- Auf einen Ausgang des Mikroprozessors festgelegt",
+ " * RName -- Merker: Ein Bit im Speicher (Internes Relais)",
+ " * TName -- Ein Timer; Anzugs- oder Abfallverzögerung",
+ " * CName -- Ein Zähler, Aufwärts- oder Abwärtszähler",
+ " * AName -- Eine Ganzzahl, von einem A/D-Wandler eingelesen",
+ " * Name -- Eine Allzweck-Variable als Ganzzahl",
+ "",
+ "Wählen Sie den Rest des Namens, sodass dieser beschreibt, was das Objekt",
+ "bewirkt und das dieser auch einmalig im Programm ist. Der gleiche Name",
+ "bezieht sich immer auf das gleiche Objekt im Programm. Es wäre zum",
+ "Beispiel falsch eine Anzugsverzögerung (TON) ‘TVerzög’ zu nennen und im",
+ "selben Programm eine Abfallverzögerung ‘TVerzög’ (TOF), weil jeder Zähler",
+ "(oder Timer) seinen eigenen Speicher benötigt. Andererseits wäre es",
+ "korrekt einen „Speichernden Timer“ (RTO) ‘TVerzög’ zu nennen und eine",
+ "entsprechende Rücksetz-Anweisung (RES) = ‘TVerzög’, weil in diesem",
+ "Fall beide Befehle dem gleichen Timer gelten.",
+ "",
+ "Die Namen von Variablen können aus Buchstaben, Zahlen und Unter-",
+ "strichen (_) bestehen. Der Name einer Variablen darf nicht mit einer",
+ "Nummer beginnen. Die Namen von Variablen sind fallabhängig.",
+ "",
+ "Ein Befehl für eine gewöhnliche Variable (MOV, ADD, EQU, usw.), kann",
+ "mit Variablen mit jedem Namen arbeiten. Das bedeutet, dass diese Zugang",
+ "zu den Timer- und Zähler-Akkumulatoren haben. Das kann manchmal recht",
+ "hilfreich sein; zum Beispiel kann man damit prüfen, ob die Zählung eines",
+ "Timers in einem bestimmten Bereich liegt.",
+ "",
+ "Die Variablen sind immer 16-Bit Ganzzahlen. Das heißt sie können von",
+ "-32768 bis 32767 reichen. Die Variablen werden immer als vorzeichen-",
+ "behaftet behandelt. Sie können auch Buchstaben als Dezimalzahlen festlegen",
+ "(0, 1234, -56). Auch können Sie ASCII-Zeichenwerte (‘A’, ‘z’) festlegen,",
+ "indem Sie die Zeichen in „Auslassungszeichen“ einfügen. Sie können",
+ "ein ASCII-Zeichen an den meisten Stellen verwenden, an denen Sie eine",
+ "Dezimalzahl verwenden können.",
+ "",
+ "Am unteren Ende der Maske (Bildanzeige) sehen Sie eine Liste aller",
+ "Objekte (Anweisungen, Befehle) des Programms. Diese Liste wird vom",
+ "Programm automatisch erzeugt; es besteht somit keine Notwendigkeit diese",
+ "von Hand auf dem Laufenden zu halten. Die meisten Objekte benötigen",
+ "keine Konfiguration. ‘XName’, ‘YName’, und ‘AName’ Objekte allerdings,",
+ "müssen einem Pin des Mikroprozessors zugeordnet werden. Wählen Sie zuerst",
+ "welcher Prozessor verwendet wird (Voreinstellungen -> Prozessor). Danach",
+ "legen Sie Ihre E/A Pins fest, indem Sie in der Liste auf diese jeweils",
+ "doppelklicken.",
+ "",
+ "Sie können das Programm verändern, indem Sie Anweisungen (Befehle)",
+ "einfügen oder löschen. Die Schreibmarke (cursor)im Programm blinkt,",
+ "um die momentan gewählte Anweisung und den Einfügungspunkt anzuzeigen.",
+ "Falls diese nicht blinkt, so drücken Sie den <Tabulator> oder klicken",
+ "Sie auf eine Anweisung. Jetzt können Sie die momentane Anweisung löschen",
+ "oder eine neue Anweisung einfügen; links oder rechts (in Reihenschaltung)",
+ "oder über oder unter (in Parallelschaltung) mit der gewählten Anweisung.",
+ "Einige Handhabungen sind nicht erlaubt, so zum Beispiel weitere",
+ "Anweisungen rechts von einer Spule.",
+ "",
+ "Das Programm beginnt mit nur einem Netzwerk. Sie können mehr Netzwerke",
+ "hinzufügen, indem Sie ‘Netzwerk Einfügen Davor/Danach’ im Programm-Menü",
+ "wählen. Den gleichen Effekt könnten Sie erzielen, indem Sie viele",
+ "komplizierte parallele Unterschaltungen in einem einzigen Netzwerk",
+ "unterbringen. Es ist aber übersichtlicher, mehrere Netzwerke zu verwenden.",
+ "",
+ "Wenn Sie Ihr Programm fertig geschrieben haben, so können Sie dieses",
+ "mit der Simulation testen. Danach können Sie es in eine Hex-Datei für",
+ "den zugedachten Mikroprozessor kompilieren.",
+ "",
+ "",
+ "SIMULATION",
+ "==========",
+ "",
+ "Um den Simulationsbetrieb einzugeben, wählen Sie ‘Simulieren ->",
+ "Simulationsbetrieb’ oder drücken Sie <Strg+M>. Das Programm wird",
+ "im Simulationsbetrieb unterschiedlich dargestellt. Es gibt keine",
+ "Schreibmarke (cursor) mehr. Die „erregten“ Anweisungen erscheinen hellrot,",
+ "die „nicht erregten“ erscheinen grau. Drücken Sie die Leertaste, um das",
+ "SPS-Programm nur einen einzelnen Zyklus durchlaufen zu lassen. Wählen",
+ "Sie für einen kontinuierlichen Umlauf in Echtzeit ‘Simulieren -> Start",
+ "Echtzeit-Simulation’ oder drücken Sie <Strg+R>. Die Maske (Bildanzeige)",
+ "des Programms wird jetzt in Echtzeit, entsprechend der Änderungen des",
+ "Status (des Zustands) des Programms aktualisiert.",
+ "",
+ "Sie können den Status (Zustand) eines Eingangs im Programm einstellen,",
+ "indem Sie auf den jeweiligen auf der Liste am unteren Ende der",
+ "Maske (Bildanzeige) doppelklicken oder auf die jeweilige ‘XName’",
+ "Kontakt-Anweisung im Programm. Wenn Sie den Status (Zustand) eines",
+ "Eingangs-Pins ändern, so wird diese Änderung nicht unmittelbar in",
+ "der Maske (Bildanzeige) wiedergegeben, sondern erst wenn sich die",
+ "SPS im zyklischen Umlauf befindet. Das geschieht automatisch wenn das",
+ "SPS-Programm in Echtzeit-Simulation läuft, oder wenn Sie die Leertaste",
+ "drücken.",
+ "",
+ "",
+ "KOMPILIEREN ZUM SYSTEMSPEZIFISCHEN CODE",
+ "=======================================",
+ "",
+ "Letztlich ist es dann nur sinnvoll eine .hex Datei zu erzeugen, mit",
+ "der Sie Ihren Mikroprozessor programmieren können. Zunächst müssen",
+ "Sie die Teilenummer des Mikroprozessors im Menü ‘Voreinstellungen ->",
+ "Prozessor’ wählen. Danach müssen jedem ‘XName’ oder ‘YName’ Objekt",
+ "einen E/A-Pin zuweisen. Tun Sie dies, indem auf den Namen des Objekts",
+ "doppelklicken, welcher sich in der Liste ganz unten in der Maske",
+ "(Bildanzeige) befindet. Ein Dialogfenster wird dann erscheinen und Sie",
+ "können daraufhin einen noch nicht vergebenen Pin von der Liste aussuchen.",
+ "",
+ "Als nächstes müssen Sie die Zykluszeit wählen, mit der Sie das",
+ "Programm laufen lassen wollen, auch müssen Sie dem Compiler mitteilen",
+ "mit welcher Taktgeschwindigkeit der Prozessor arbeiten soll. Diese",
+ "Einstellungen werden im Menü ‘Voreinstellungen -> Prozessor Parameter...’",
+ "vorgenommen. Üblicherweise sollten Sie die Zykluszeit nicht ändern,",
+ "denn diese ist auf 10ms voreingestellt, dies ist ein guter Wert für",
+ "die meisten Anwendungen. Tippen Sie die Frequenz des Quarzes (oder des",
+ "Keramik-Resonators) ein, mit der Sie den Prozessor betreiben wollen und",
+ "klicken auf Okay.",
+ "",
+ "Jetzt können Sie einen Code von Ihrem Programm erzeugen. Wählen Sie",
+ "‘Kompilieren -> Kompilieren’ oder ‘Kompilieren -> Kompilieren unter...’,",
+ "falls Sie vorher Ihr Programm schon kompiliert haben und einen neuen Namen",
+ "für die Ausgangsdatei vergeben wollen. Wenn Ihr Programm fehlerfrei ist,",
+ "wird LDmicro eine Intel IHEX Datei erzeugen, mit der sich Ihr Prozessor",
+ "programmieren lässt.",
+ "",
+ "Verwenden Sie hierzu irgendeine Programmier Soft- und Hardware, die Sie",
+ "besitzen, um die Hex-Datei in den Mikroprozessor zu laden. Beachten Sie",
+ "die Einstellungen für die Konfigurationsbits (fuses)! Bei den PIC16",
+ "Prozessoren sind diese Konfigurationsbits bereits in der Hex-Datei",
+ "enthalten. Die meisten Programmiersoftwares schauen automatisch nach",
+ "diesen. Für die AVR-Prozessoren müssen Sie die Konfigurationsbits von",
+ "Hand einstellen.",
+ "",
+ "",
+ "ANWEISUNGS-VERZEICHNIS",
+ "======================",
+ "",
+ "> KONTAKT, SCHLIESSER XName RName YName",
+ " ----] [---- ----] [---- ----] [----",
+ "",
+ "Wenn ein ‘unwahres’ Signal diese Anweisung erreicht, so ist das",
+ "Ausgangssignal ‘unwahr’. Wenn ein ‘wahres’ Signal diese Anweisung",
+ "erreicht, so ist das Ausgangssignal ‘wahr’. Dies nur, falls der",
+ "vorliegende Eingangspin, Ausgangspin oder eines Merkers (Hilfsrelais)",
+ "‘wahr’ ist, anderenfalls ist es unwahr. Diese Anweisung fragt den Status",
+ "(Zustand) eines Eingangspins, Ausgangspins oder Merkers (Hilfsrelais) ab.",
+ "",
+ "",
+ "> KONTAKT, ÖFFNER XName RName YName",
+ " ----]/[---- ----]/[---- ----]/[----",
+ "",
+ "Wenn ein ‘unwahres’ Signal diese Anweisung erreicht, so ist das",
+ "Ausgangssignal ‘unwahr’. Wenn ein ‘wahres’ Signal diese Anweisung",
+ "erreicht, so ist das Ausgangssignal ‘wahr’. Dies nur, falls der",
+ "vorliegende Eingangspin, Ausgangspin oder der Merker (= internes",
+ "Hilfsrelais) ‘unwahr’ ist, anderenfalls ist es ‘unwahr’. Diese Anweisung",
+ "fragt den Status (Zustand) eines Eingangspins, Ausgangspins oder Merkers",
+ "(Hilfsrelais) ab. Dies ist das Gegenteil eines Schließers.",
+ "",
+ "",
+ "> SPULE, NORMAL (MERKER,AUSGANG) RName YName",
+ " ----( )---- ----( )----",
+ "",
+ "Wenn ein ‘unwahres’ Signal diese Anweisung erreicht, so wird der",
+ "vorliegende Merker (Hilfsrelais) oder Ausgangspin nicht angesteuert. Wenn",
+ "ein ‘wahres’ Signal diese Anweisung erreicht, so wird der vorliegende",
+ "Merker (Hilfsrelais) oder Ausgangspin angesteuert. Es ist nicht sinnvoll",
+ "dieser Spule eine Eingangsvariable zuzuweisen. Diese Anweisung muss",
+ "ganz rechts im Netzwerk stehen.",
+ "",
+ "",
+ "> SPULE, NEGIERT (MERKER,AUSGANG) RName YName",
+ " ----(/)---- ----(/)----",
+ "",
+ "Wenn ein ‘wahres’ Signal diese Anweisung erreicht, so wird der vorliegende",
+ "Merker (Hilfsrelais)oder Ausgangspin nicht angesteuert. Wenn ein",
+ "‘unwahres’ Signal diese Anweisung erreicht, so wird der vorliegende Merker",
+ "(Hilfsrelais) oder Ausgangspin angesteuert. Es ist nicht sinnvoll dieser",
+ "Spule eine Eingangsvariable zuzuweisen. Dies ist das Gegenteil einer",
+ "normalen Spule. Diese Anweisung muss im Netzwerk ganz rechts stehen.",
+ "",
+ "",
+ "> SPULE, SETZEN RName YName",
+ " ----(S)---- ----(S)----",
+ "",
+ "Wenn ein ‘wahres’ Signal diese Anweisung erreicht, so wird der vorliegende",
+ "Merker (Hilfsrelais)oder Ausgangspin auf ‘wahr’ gesetzt. Anderenfalls",
+ "bleibt der Status (Zustand) des Merkers (Hilfsrelais) oder Ausgangspins",
+ "unverändert. Diese Anweisung kann nur den Status (Zustand) einer Spule",
+ "von ‘unwahr’ nach ‘wahr’ verändern, insofern wird diese üblicherweise in",
+ "einer Kombination mit einer Rücksetz-Anweisung für eine Spule verwendet.",
+ "Diese Anweisung muss ganz rechts im Netzwerk stehen.",
+ "",
+ "",
+ "> SPULE, RÜCKSETZEN RName YName",
+ " ----(R)---- ----(R)----",
+ "",
+ "Wenn ein ‘wahres’ Signal diese Anweisung erreicht, so wird der vorliegende",
+ "Merker (Hilfsrelais) oder Ausgangspin rückgesetzt. Anderenfalls bleibt der",
+ "Status (Zustand) des Merkers (Hilfsrelais) oder Ausgangspins unverändert.",
+ "Diese Anweisung kann nur den Status (Zustand) einer Spule von ‘wahr’ nach",
+ "‘unwahr’ verändern, insofern wird diese üblicherweise in einer Kombination",
+ "mit einer Setz-Anweisung für eine Spule verwendet. Diese Anweisung muss",
+ "ganz rechts im Netzwerk stehen.",
+ "",
+ "",
+ "> ANZUGSVERZÖGERUNG Tdon",
+ " -[TON 1.000 s]-",
+ "",
+ "Wenn ein Signal diese Anweisung erreicht, welches seinen Status",
+ "(Zustand) von ‘unwahr’ nach ‘wahr’ ändert, so bleibt das Ausgangssignal",
+ "für 1,000 s ‘unwahr’, dann wird es ‘wahr’. Wenn ein Signal diese",
+ "Anweisung erreicht, welches seinen Status (Zustand) von ‘wahr’ nach",
+ "‘unwahr’ ändert, so wird das Ausgangssignal sofort ‘unwahr’. Der Timer",
+ "wird jedes Mal rückgesetzt (bzw. auf Null gesetzt), wenn der Eingang",
+ "‘unwahr’ wird. Der Eingang muss für 1000 aufeinanderfolgende Millisekunden",
+ "‘wahr’ bleiben, bevor auch der Ausgang ‘wahr’ wird. Die Verzögerung",
+ "ist konfigurierbar.",
+ "",
+ "Die ‘TName’ Variable zählt, in der Einheit der jeweiligen Zykluszeit,",
+ "von Null ab hoch. Der Ausgang der TON-Anweisung wird wahr, wenn die",
+ "Zählervariable größer oder gleich der vorliegenden Verzögerung ist.",
+ "Es möglich die Zählervariable an einer anderen Stelle im Programm zu",
+ "bearbeiten, zum Beispiel mit einer TRANSFER-Anweisung (MOV).",
+ "",
+ "",
+ "> ABFALLVERZÖGERUNG Tdoff",
+ " -[TOF 1.000 s]-",
+ "",
+ "Wenn ein Signal diese Anweisung erreicht, welches seinen Status",
+ "(Zustand) von ‘wahr’ nach ‘unwahr’ ändert, so bleibt das Ausgangssignal",
+ "für 1,000 s ‘wahr’, dann wird es ‘unwahr’. Wenn ein Signal diese",
+ "Anweisung erreicht, welches seinen Status (Zustand) von ‘unwahr’ nach",
+ "‘wahr’ ändert, so wird das Ausgangssignal sofort ‘wahr’. Der Timer wird",
+ "jedes Mal rückgesetzt (bzw. auf Null gesetzt), wenn der Eingang ‘unwahr’",
+ "wird. Der Eingang muss für 1000 aufeinanderfolgende Millisekunden ‘unwahr’",
+ "bleiben, bevor auch der Ausgang ‘unwahr’ wird. Die Verzögerung ist",
+ "konfigurierbar.",
+ "",
+ "Die ‘TName’ Variable zählt, in der Einheit der jeweiligen Zykluszeit,",
+ "von Null ab hoch. Der Ausgang der TOF Anweisung wird wahr, wenn die",
+ "Zählervariable größer oder gleich der vorliegenden Verzögerung ist.",
+ "Es möglich die Zählervariable an einer anderen Stelle im Programm zu",
+ "bearbeiten, zum Beispiel mit einer TRANSFER-Anweisung (MOV).",
+ "",
+ "",
+ "> SPEICHERNDER TIMER Trto",
+ " -[RTO 1.000 s]-",
+ "",
+ "Diese Anweisung zeichnet auf, wie lange sein Eingang ‘wahr’ gewesen",
+ "ist. Wenn der Eingang für mindestens 1.000 s ‘wahr’ gewesen ist, dann",
+ "wird der Ausgang ‘wahr’. Andernfalls ist er ‘unwahr’. Der Eingang muss",
+ "für 1000 aufeinanderfolgende Millisekunden ‘wahr’ gewesen sein; wenn",
+ "der Eingang für 0,6 s ‘wahr’ war, dann ‘unwahr’ für 2,0 s und danach für",
+ "0,4 s wieder ‘wahr’, so wird sein Ausgang ‘wahr’. Nachdem der Ausgang",
+ "‘wahr’ wurde, so bleibt er ‘wahr’, selbst wenn der Eingang ‘unwahr’",
+ "wird, so lange der Eingang für länger als 1.000 s ‘wahr’ gewesen ist.",
+ "Der Timer muss deshalb von Hand mit Hilfe der Rücksetz-Anweisung",
+ "rückgesetzt (auf Null gesetzt) werden.",
+ "",
+ "Die ‘TName’ Variable zählt, in der Einheit der jeweiligen Zykluszeit,",
+ "von Null ab hoch. Der Ausgang der RTO-Anweisung wird wahr, wenn die",
+ "Zählervariable größer oder gleich der vorliegenden Verzögerung ist.",
+ "Es möglich die Zählervariable an einer anderen Stelle im Programm zu",
+ "bearbeiten, zum Beispiel mit einer TRANSFER-Anweisung (MOV).",
+ "",
+ "",
+ "> RÜCKSETZEN Trto Citems",
+ " ----{RES}---- ----{RES}----",
+ "",
+ "Diese Anweisung rücksetzt einen Timer oder Zähler. TON oder TOF Timer",
+ "werden automatisch rückgesetzt, wenn ihr Eingang ‘wahr’ oder ‘unwahr’",
+ "wird, somit ist die RES-Anweisung für diese Timer nicht erforderlich. RTO",
+ "Timer und CTU/CTD Zähler werden nicht automatisch rückgesetzt, somit",
+ "müssen diese von Hand mit Hilfe der RES-Anweisung rückgesetzt (auf Null)",
+ "werden. Wenn der Eingang ‘wahr’ ist, so wird der Timer oder Zähler",
+ "rückgesetzt; wenn der Eingang ‘unwahr’ ist, so erfolgt keine Aktion.",
+ "Diese Anweisung muss ganz rechts im Netzwerk stehen.",
+ "",
+ " _",
+ "> ONE-SHOT RISING, STEIGENDE FLANKE --[OSR_/ ]--",
+ "",
+ "Diese Anweisung wird normalerweise ‘unwahr’ ausgewiesen. Wenn der Eingang",
+ "der Anweisung während des momentanen Zyklus ‘wahr’ ist und während des",
+ "vorgehenden ‘unwahr’ war, so wird der Ausgang ‘wahr’. Daher erzeugt diese",
+ "Anweisung bei jeder steigenden Flanke einen Impuls für einen Zyklus.",
+ "Diese Anweisung ist hilfreich, wenn Sie Ereignisse an der steigenden",
+ "Flanke eines Signals auslösen wollen.",
+ "",
+ " _",
+ "> ONE-SHOT FALLING, FALLENDE FLANKE --[OSF \\_ ]--",
+ "",
+ "Diese Anweisung wird normalerweise ‘unwahr’ ausgewiesen. Wenn der Eingang",
+ "der Anweisung während des momentanen Zyklus ‘unwahr’ ist und während des",
+ "vorgehenden ‘wahr’ war, so wird der Ausgang ‘wahr’. Daher erzeugt diese",
+ "Anweisung bei jeder fallenden Flanke einen Impuls für einen Zyklus.",
+ "Diese Anweisung ist hilfreich, wenn Sie Ereignisse an der fallenden",
+ "Flanke eines Signals auslösen wollen.",
+ "",
+ "",
+ "> BRÜCKE, ÖFFNUNG ----+----+---- ----+ +----",
+ "",
+ "Der Eingangszustand einer Brücke ist immer gleich seinem Ausgangszustand.",
+ "Der Ausgangszustands einer Öffnung ist immer ‘unwahr’. Diese Anweisungen",
+ "sind bei der Fehlerbehebung (debugging) besonders hilfreich.",
+ "",
+ "",
+ "> MASTER CONTROL RELAIS -{MASTER RLY}-",
+ "",
+ "",
+ "Im Normalfall ist der Anfang (die linke Stromschiene) von jedem Netzwerk",
+ "‘wahr’. Wenn eine ‘Master Control Relais’ Anweisung ausgeführt wird dessen",
+ "Eingang ‘unwahr’ ist, so werden die Anfänge (die linke Stromschiene)",
+ "aller folgenden Netzwerke ‘unwahr’. Das setzt sich fort bis die nächste",
+ "‘Master Control Relais’ Anweisung erreicht wird (unabhängig von dem",
+ "Anfangszustand dieser Anweisung). Diese Anweisungen müssen daher als Paar",
+ "verwendet werden: Eine (vielleicht abhängige), um den „gegebenenfalls",
+ "gesperrten“ Abschnitt zu starten und eine weitere, um diesen zu beenden.",
+ "",
+ "",
+ "> TRANSFER, MOV {destvar := } {Tret := }",
+ " -{ 123 MOV}- -{ srcvar MOV}-",
+ "",
+ "Wenn der Eingang dieser Anweisung ‘wahr’ ist, so setzt diese die",
+ "vorliegende Zielvariable gleich der vorliegenden Quellvariablen",
+ "oder Konstanten. Wenn der Eingang dieser Anweisung ‘unwahr’ ist, so",
+ "geschieht nichts. Mit der TRANSFER-Anweisung (MOV) können Sie jede",
+ "Variable zuweisen; dies schließt Timer und Zähler Statusvariablen ein,",
+ "welche mit einem vorgestellten ‘T’ oder ‘C’ unterschieden werden. Eine",
+ "Anweisung zum Beispiel, die eine ‘0’ in einen ‘TBewahrend’ transferiert,",
+ "ist äquivalent mit einer RES-Anweisung für diesen Timer. Diese Anweisung",
+ "muss ganz rechts im Netzwerk stehen.",
+ "",
+ "",
+ "> ARITHMETISCHE OPERATIONEN {ADD kay :=} {SUB Ccnt :=}",
+ " -{ 'a' + 10 }- -{ Ccnt - 10 }-",
+ "",
+ "> {MUL dest :=} {DIV dv := }",
+ " -{ var * -990 }- -{ dv / -10000}-",
+ "",
+ "Wenn der Eingang einer dieser Anweisungen ‘wahr’ ist, so setzt diese",
+ "die vorliegende Zielvariable gleich dem vorliegenden arithmetischem",
+ "Ausdruck. Die Operanden können entweder Variabelen (einschließlich Timer-",
+ "und Zählervariabelen) oder Konstanten sein. Diese Anweisungen verwenden",
+ "16-Bitzeichen Mathematik. Beachten Sie, dass das Ergebnis jeden Zyklus",
+ "ausgewertet wird, wenn der Eingangszustand ‘wahr’ ist. Falls Sie eine",
+ "Variable inkrementieren oder dekrementieren (d.h., wenn die Zielvariable",
+ "ebenfalls einer der Operanden ist), dann wollen Sie dies vermutlich",
+ "nicht; normalerweise würden Sie einen Impuls (one-shot) verwenden,",
+ "sodass die Variable nur bei einer steigenden oder fallenden Flanke des",
+ "Eingangszustands ausgewertet wird. Dividieren kürzt: D.h. 8 / 3 = 2.",
+ "Diese Anweisungen müssen ganz rechts im Netzwerk stehen.",
+ "",
+ "",
+ "> VERGLEICHEN [var ==] [var >] [1 >=]",
+ " -[ var2 ]- -[ 1 ]- -[ Ton]-",
+ "",
+ "> [var /=] [-4 < ] [1 <=]",
+ " -[ var2 ]- -[ vartwo]- -[ Cup]-",
+ "",
+ "Wenn der Eingang dieser Anweisung ‘unwahr’ ist, so ist der Ausgang",
+ "auch ‘unwahr’. Wenn der Eingang dieser Anweisung ‘wahr’ ist, dann ist",
+ "Ausgang ‘wahr’; dies aber nur, wenn die vorliegende Bedingung ‘wahr’",
+ "ist. Diese Anweisungen können zum Vergleichen verwendet werden, wie:",
+ "Auf gleich, auf größer als, auf größer als oder gleich, auf ungleich,",
+ "auf kleiner als, auf kleiner als oder gleich, eine Variable mit einer",
+ "Variablen oder eine Variable mit einer 16-Bitzeichen-Konstanten.",
+ "",
+ "",
+ "> ZÄHLER CName CName",
+ " --[CTU >=5]-- --[CTD >=5]—",
+ "",
+ "Ein Zähler inkrementiert (CTU, aufwärtszählen) oder dekrementiert",
+ "(CTD, abwärtszählen) die bezogene Zählung bei jeder steigenden Flanke",
+ "des Eingangszustands des Netzwerks (d.h. der Eingangszustand des",
+ "Netzwerks geht von ‘unwahr’ auf ‘wahr’ über). Der Ausgangszustand des",
+ "Zählers ist ‘wahr’, wenn die Zähler- variable ist größer oder gleich 5",
+ "und andernfalls ‘unwahr’. Der Ausgangszustand des Netzwerks kann ‘wahr’",
+ "sein, selbst wenn der Eingangszustand ‘unwahr’ ist; das hängt lediglich",
+ "von Zählervariablen ab. Sie können einer CTU- und CTD-Anweisung den",
+ "gleichen Namen zuteilen, um den gleichen Zähler zu inkrementieren und",
+ "dekrementieren. Die RES-Anweisung kann einen Zähler rücksetzen oder auch",
+ "eine gewöhnliche Variablen-Operation mit der Zählervariablen ausführen.",
+ "",
+ "",
+ "> ZIRKULIERENDER ZÄHLER CName",
+ " --{CTC 0:7}--",
+ "",
+ "Ein zirkulierender Zähler arbeitet wie ein normaler CTU-Zähler, außer",
+ "nach der Erreichung seiner Obergrenze, rücksetzt er seine Zählervariable",
+ "auf Null. Zum Beispiel würde der oben gezeigte Zähler, wie folgt zählen:",
+ "0, 1, 2, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2,.... Dies ist",
+ "hilfreich in Kombination mit bedingten Anweisungen der Variablen‘CName’;",
+ "Sie können dies als eine Folgeschaltung verwenden. CTC-Zähler takten",
+ "mit der aufsteigenden Flanke der Eingangsbedingung des Netzwerks.",
+ "Diese Anweisung muss ganz rechts im Netzwerk stehen.",
+ "",
+ "",
+ "> SCHIEBEREGISTER {SHIFT REG }",
+ " -{ reg0..3 }-",
+ "",
+ "Ein Schieberegister besteht aus einer Reihe von Variablen. So bestünde",
+ "zum Beispiel ein Schieberegister aus den Variablen ‘reg0’, ‘reg1’,",
+ "‘reg2’, and ‘reg3’. Der Eingang des Schieberegisters ist ‘reg0’. Bei",
+ "jeder steigenden Flanke der Eingansbedingung des Netzwerks, schiebt das",
+ "Schieberegister nach rechts. Dies bedeutet es wie folgt zuweist: ‘reg3’",
+ "nach ‘reg2’, ‘reg2’ nach ‘reg1’ und ‘reg1’ nach ‘reg0’. ‘reg0’ bleibt",
+ "unverändert. Ein großes Schieberegister kann leicht viel Speicherplatz",
+ "belegen. Diese Anweisung muss ganz rechts im Netzwerk stehen.",
+ "",
+ "",
+ "> NACHSCHLAG-TABELLE {dest := }",
+ " -{ LUT[i] }-",
+ "",
+ "Eine Nachschlag-Tabelle ist eine Anordnung von n Werten. Wenn die",
+ "Eingangsbedingung des Netzwerks ‘wahr’ ist, so wird die Ganzzahl-Variable",
+ "‘dest’ mit dem Eintrag in der Nachschlag-Tabelle gleichgesetzt, der der",
+ "Ganzzahl-Variablen ‘i’ entspricht. Das Verzeichnis beginnt bei Null,",
+ "insofern muss sich ‘i’ zwischen 0 und (n-1) befinden. Das Verhalten",
+ "dieser Anweisung ist undefiniert, wenn sich die Werte des Verzeichnisses",
+ "außerhalb dieses Bereichs befinden.",
+ "",
+ "",
+ "> NÄHERUNGS-LINEAR-TABELLE {yvar :=}",
+ " -{PWL[xvar] }-",
+ "",
+ "Dies ist eine gute Methode für die Näherungslösung einer komplizierten",
+ "Funktion oder Kurve. Sie könnte zum Beispiel hilfreich sein, wenn Sie",
+ "versuchen eine Eichkurve zu verwenden, um die rohe Ausgangsspannung",
+ "eines Fühlers in günstigere Einheiten zu wandeln.",
+ "",
+ "Angenommen Sie versuchen eine Näherungslösung für eine Funktion zu finden,",
+ "die eine Eingangs-Ganzzahlvariable ‘x’ in Ausgangs-Ganzzahlvariable ‘y’",
+ "wandelt. Einige Punkte der Funktion sind Ihnen bekannt; so würden Sie",
+ "z.B. die folgenden kennen:",
+ "",
+ " f(0) = 2",
+ " f(5) = 10",
+ " f(10) = 50",
+ " f(100) = 100",
+ "",
+ "Dies bedeutet, dass sich die Punkte",
+ "",
+ " (x0, y0) = ( 0, 2)",
+ " (x1, y1) = ( 5, 10)",
+ " (x2, y2) = ( 10, 50)",
+ " (x3, y3) = (100, 100)",
+ "",
+ "in dieser Kurve befinden. Diese 4 Punkte können Sie in die Tabelle der",
+ "‘Näherungs-Linear’-Anweisung eintragen. Die ‘Näherungs-Linear’-Anweisung",
+ "wird dann auf den Wert von ‘xvar’ schauen und legt den Wert von ‘yvar’",
+ "fest. Sie stellt ‘yvar’ so ein, dass die ‘Näherungs-Linear’-Kurve sich",
+ "durch alle Punkte bewegt, die Sie vorgegeben haben. Wenn Sie z.B. für",
+ "‘xvar’ = 10 vorgegeben haben, dann stellt die Anweisung ‘yvar’ auf gleich",
+ "50 ein.",
+ "",
+ "Falls Sie dieser Anweisung einen Wert ‘xvar’ zuweisen, der zwischen zwei",
+ "Werten von ‘x’ liegt, denen Sie Punkte zugeordnet haben, dann stellt die",
+ "Anweisung ‘yvar’ so ein, dass (‘xvar’, ‘yvar’) in der geraden Linie liegt;",
+ "diejenige die, die zwei Punkte in der Tabelle verbindet. Z.B. erzeugt",
+ "‘xvar’ = 55 bei ‘yvar’ = 75. Die beiden Punkte in der Tabelle sind (10,",
+ "50) und (100, 100). 55 liegt auf halbem Weg zwischen 10 und 100 und 75",
+ "liegt auf halbem Weg zwischen 50 und 100, somit liegt (55, 75) auf der",
+ "Linie, die diese zwei Punkte verbindet.",
+ "",
+ "Die Punkte müssen in aufsteigender Reihenfolge der x-Koordinaten",
+ "angegeben werden. Einige mathematische Operationen, erforderlich für",
+ "bestimmte Nachschlag-Tabellen mit 16-Bit-Mathematik, kann man ggf. nicht",
+ "ausführen. In diesem Falle gibt LDmicro eine Warnmeldung aus. So würde",
+ "z.B. die folgende Nachschlag-Tabelle eine Fehlermeldung hervorrufen:",
+ "",
+ " (x0, y0) = ( 0, 0)",
+ " (x1, y1) = (300, 300)",
+ "",
+ "Sie können diesen Fehler beheben, indem sie den Abstand zwischen den",
+ "Punkten kleiner machen. So ist zum Beispiel die nächste Tabelle äquivalent",
+ "zur vorhergehenden, ruft aber keine Fehlermeldung hervor.",
+ "",
+ " (x0, y0) = ( 0, 2)",
+ " (x1, y1) = (150, 150)",
+ " (x2, y2) = (300, 300)",
+ "",
+ "Es wird kaum einmal notwendig sein, mehr als fünf oder sechs Punkte",
+ "zu verwenden. Falls Sie mehr Punkte hinzufügen, so vergrößert dies",
+ "Ihren Code und verlangsamt die Ausführung. Falls Sie für ‘xvar’ einen",
+ "Wert vergeben, der größer ist, als die größte x-Koordinate der Tabelle",
+ "oder kleiner, als die kleinste x-Koordinate in der Tabelle, so ist das",
+ "Verhalten der Anweisung undefiniert. Diese Anweisung muss ganz rechts",
+ "im Netzwerk stehen.",
+ "",
+ "",
+ "> A/D-WANDLER EINLESEN AName",
+ " --{READ ADC}--",
+ "",
+ "LDmicro kann einen Code erzeugen, der ermöglicht, die A/D-Wandler",
+ "zu verwenden, die in manchen Mikroprozessoren vorgesehen sind.",
+ "Wenn der Eingangszustand dieser Anweisung ‘wahr’ ist, dann wird eine",
+ "Einzellesung von dem A/D-Wandler entnommen und in der Variablen ‘AName’",
+ "gespeichert. Diese Variable kann anschließend mit einer gewöhnlichen",
+ "Ganzzahlvariablen bearbeitet werden (wie: Kleiner als, größer als,",
+ "arithmetisch usw.). Weisen Sie ‘Axxx’ in der gleichen Weise einen Pin",
+ "zu, wie Sie einen Pin für einen digitalen Ein- oder Ausgang vergeben",
+ "würden, indem auf diesen in der Liste unten in der Maske (Bildanzeige)",
+ "doppelklicken. Wenn der Eingangszustand dieses Netzwerks ‘unwahr’ ist,",
+ "so wird die Variable ‘AName’ unverändert belassen.",
+ "",
+ "Für alle derzeitig unterstützten Prozessoren gilt: Eine 0 Volt Lesung",
+ "am Eingang des A/D-Wandlers entspricht 0. Eine Lesung gleich der",
+ "Versorgungsspannung (bzw. Referenzspannung) entspricht 1023. Falls Sie",
+ "AVR-Prozessoren verwenden, so verbinden Sie AREF mit Vdd. (Siehe Atmel",
+ "Datenblatt, dort wird eine Induktivität von 100µH empfohlen). Sie können",
+ "arithmetische Operationen verwenden, um einen günstigeren Maßstabfaktor",
+ "festzulegen, aber beachten Sie, dass das Programm nur Ganzzahl-Arithmetik",
+ "vorsieht. Allgemein sind nicht alle Pins als A/D-Wandler verwendbar. Die",
+ "Software gestattet Ihnen nicht, einen Pin zuzuweisen, der kein A/D",
+ "bzw. analoger Eingang ist. Diese Anweisung muss ganz rechts im Netzwerk",
+ "stehen.",
+ "",
+ "",
+ "> PULSWEITEN MODULATIONSZYKLUS FESTLEGEN duty_cycle",
+ " -{PWM 32.8 kHz}-",
+ "",
+ "LDmicro kann einen Code erzeugen, der ermöglicht, die PWM-Peripherie",
+ "zu verwenden, die in manchen Mikroprozessoren vorgesehen ist. Wenn die",
+ "Eingangsbedingung dieser Anweisung ‘wahr’ ist, so wird der Zyklus der",
+ "PWM-Peripherie mit dem Wert der Variablen ‘duty cycle’ gleichgesetzt. Der",
+ "‘duty cycle’ muss eine Zahl zwischen 0 und 100 sein. 0 entspricht immer",
+ "‘low’ und 100 entsprechend immer ‘high’. (Wenn Sie damit vertraut sind,",
+ "wie die PWM-Peripherie funktioniert, so bemerken Sie, dass dies bedeutet,",
+ "dass LDmicro die ‘duty cycle’-Variable automatisch prozentual zu den",
+ "PWM-Taktintervallen skaliert [= den Maßstabfaktor festlegt].)",
+ "",
+ "Sie können die PWM-Zielfrequenz in Hz definieren. Es kann vorkommen, dass",
+ "die angegebene Frequenz nicht genau erreicht wird, das hängt davon ab,",
+ "wie sich diese innerhalb der Taktfrequenz des Prozessors einteilt. LDmicro",
+ "wählt dann die nächst erreichbare Frequenz; falls der Fehler zu groß ist,",
+ "so wird eine Warnung ausgegeben. Höhere Geschwindigkeiten können die",
+ "Auflösung beeinträchtigen.",
+ "",
+ "Diese Anweisung muss ganz rechts im Netzwerk stehen. Die ‘ladder",
+ "logic’-Laufzeit verbraucht (schon) einen Timer, um die Zykluszeit",
+ "zu messen. Dies bedeutet, dass die PWM nur bei den Mikroprozessoren",
+ "verfügbar ist, bei denen mindestens zwei geeignete Timer vorhanden sind.",
+ "PWM verwendet den PIN CCP2 (nicht CCP1) bei den PIC16-Prozessoren und",
+ "OC2 (nicht OC1A) bei den AVR-Prozessoren.",
+ "",
+ "",
+ "> REMANENT MACHEN saved_var",
+ " --{PERSIST}--",
+ "",
+ "Wenn der Eingangszustand dieser Anweisung ‘wahr’ ist, so bewirkt",
+ "dies, dass eine angegebene Ganzzahl-Variable automatisch im EEPROM",
+ "gespeichert wird. Dies bedeutet, dass ihr Wert bestehen bleiben wird,",
+ "auch wenn der Prozessor seine Versorgungsspannung verliert. Es ist",
+ "nicht notwendig, die Variable an klarer Stelle im EEPROM zu speichern,",
+ "dies geschieht automatisch, so oft sich der Wert der Variablen",
+ "ändert. Bei Spannungswiederkehr wird die Variable automatisch vom",
+ "EEPROM zurückgespeichert. Falls eine Variable, die häufig ihren Wert",
+ "ändert, remanent (dauerhaft) gemacht wird, so könnte Ihr Prozessor sehr",
+ "rasch verschleißen, weil dieser lediglich für eine begrenzte Anzahl von",
+ "Schreibbefehlen konstruiert ist (~100 000). Wenn der Eingangszustand des",
+ "Netzwerks ‘unwahr’ ist, so geschieht nichts. Diese Anweisung muss ganz",
+ "rechts im Netzwerk stehen.",
+ "",
+ "",
+ "> UART (SERIELL) EMPFANGEN var",
+ " --{UART RECV}--",
+ "",
+ "LDmicro kann einen Code erzeugen, der ermöglicht UART zu verwenden,",
+ "welcher in manchen Mikroprozessoren vorgesehen ist.",
+ "Bei AVR-Prozessoren mir mehrfachem UART, wird nur UART1 (nicht UART0)",
+ "unterstützt. Konfigurieren Sie die Baudrate, indem Sie ‘Voreinstellungen",
+ "-> Prozessor-Parameter’ verwenden. Bestimmte Baudraten werden mit",
+ "bestimmten Quarzfrequenzen nicht erreichbar sein. In diesem Fall gibt",
+ "LDmicro eine Warnmeldung.",
+ "",
+ "Wenn der Eingangszustand dieser Anweisung ‘unwahr’ ist, so geschieht",
+ "nichts. Wenn der Eingangszustand ‘wahr’ ist, so versucht diese Anweisung",
+ "ein einzelnes Schriftzeichen vom UART-Eingang zu empfangen. Wenn",
+ "kein Schriftzeichen eingelesen wird, dann ist der Ausgangszustand",
+ "‘unwahr’. Wenn ein ASCII-Zeichen eingelesen wird, so wird sein Wert in",
+ "‘var’ abgespeichert und der Ausgangszustand wird für einen einzelnen",
+ "Zyklus ‘wahr’.",
+ "",
+ "",
+ "> UART (SERIELL) SENDEN var",
+ " --{UART SEND}--",
+ "",
+ "LDmicro kann einen Code erzeugen, der ermöglicht UART zu verwenden,",
+ "welcher in manchen Mikroprozessoren vorgesehen ist.",
+ "Bei AVR-Prozessoren mir mehrfachem UART, wird nur UART1 (nicht UART0)",
+ "unterstützt. Konfigurieren Sie die Baudrate, indem Sie ‘Voreinstellungen",
+ "-> Prozessor-Parameter’ verwenden. Bestimmte Baudraten werden mit",
+ "bestimmten Quarzfrequenzen nicht erreichbar sein. In diesem Fall gibt",
+ "LDmicro eine Warnmeldung.",
+ "",
+ "Wenn der Eingangszustand dieser Anweisung ‘unwahr’ ist, so geschieht",
+ "nichts. Wenn der Eingangszustand ‘wahr’ ist, so schreibt diese",
+ "Anweisung ein einzelnes Schriftzeichen zum UART. Der ASCII-Wert des",
+ "Schriftzeichens, welches gesendet werden soll, muss vorher in ‘var’",
+ "abgespeichert worden sein. Der Ausgangszustand dieses Netzwerks ist",
+ "‘wahr’, wenn UART beschäftigt ist (gerade dabei ein Schriftzeichen zu",
+ "übermitteln) und andernfalls ‘unwahr’.",
+ "",
+ "Denken Sie daran, dass einige Zeit zum Senden von Schriftzeichen",
+ "beansprucht wird. Überprüfen Sie den Ausgangszustand dieser Anweisung,",
+ "sodass das erste Schriftzeichen bereits übermittelt wurde, bevor Sie",
+ "versuchen ein zweites Schriftzeichen zu übermitteln. Oder verwenden Sie",
+ "einen Timer, um eine Verzögerung zwischen die Schriftzeichen fügen. Sie",
+ "dürfen den Eingangszustand dieser Anweisung nur dann auf ‘wahr’ setzen",
+ "(bzw. ein Schriftzeichen übermitteln), wenn der Ausgangszustand ‘unwahr’",
+ "ist (bzw. UART unbeschäftigt ist).",
+ "",
+ "Untersuchen Sie die “Formatierte Zeichenfolge”-Anweisung, bevor Sie",
+ "diese Anweisung verwenden. Die “Formatierte Zeichenfolge”- Anweisung",
+ "ist viel einfacher in der Anwendung und fast sicher fähig, das zu tun,",
+ "was Sie beabsichtigen.",
+ "",
+ " ",
+ "> FORMATIERTE ZEICHENFOLGE ÜBER UART var",
+ " -{\"Druck: \\3\\r\\n\"}-",
+ "",
+ "LDmicro kann einen Code erzeugen, der ermöglicht UART zu verwenden,",
+ "welcher in manchen Mikroprozessoren vorgesehen ist.",
+ "Bei AVR-Prozessoren mir mehrfachem UART, wird nur UART1 (nicht UART0)",
+ "unterstützt. Konfigurieren Sie die Baudrate, indem Sie ‘Voreinstellungen",
+ "-> Prozessor-Parameter’ verwenden. Bestimmte Baudraten werden mit",
+ "bestimmten Quarzfrequenzen nicht erreichbar sein. In diesem Fall gibt",
+ "LDmicro eine Warnmeldung.",
+ "",
+ "Wenn der Eingangszustand des Netzwerks für diese Anweisung von ‘unwahr’",
+ "auf ‘wahr’ übergeht, so beginnt diese eine vollständige Zeichenfolge",
+ "über den seriellen Anschluss zu senden. Wenn die Zeichenfolge die",
+ "besondere Reihenfolge ‘\\3’ enthält, dann wird diese Folge durch den Wert",
+ "von ‘var’ ersetzt, welcher automatisch in eine Zeichenfolge gewandelt",
+ "wird. Die Variable wird formatiert, sodass diese exakt 3 Schriftzeichen",
+ "übernimmt. Falls die Variable zum Beispiel gleich 35 ist, dann wird die",
+ "exakte ausgegebene Zeichenfolge, wie folgt aussehen: ‘Druck: 35\\r\\n’",
+ "(beachten Sie das zusätzliche Freizeichen). Wenn stattdessen die Variable",
+ "gleich 1432 ist, so wäre das Verhalten der Anweisung undefiniert,",
+ "weil 1432 mehr als drei Stellen hat. In diesem Fall wäre es notwendig",
+ "stattdessen ‘\\4’ zu verwenden.",
+ "",
+ "Falls die Variable negativ ist, so verwenden Sie stattdessen ‘\\-3d’",
+ "(oder ‘\\-4d’). LDmicro wird hierdurch veranlasst eine vorgestellte",
+ "Freistelle für positive Zahlen und ein vorgestelltes Minuszeichen für",
+ "negative Zahlen auszugeben.",
+ "",
+ "Falls mehrere “Formatierte Zeichenfolge”-Anweisungen zugleich ausgegeben",
+ "werden (oder wenn eine neue Zeichenfolge ausgegeben wird bevor die",
+ "vorherige vollendet ist), oder auch wenn diese mit UART TX Anweisungen",
+ "vermischt, so ist das Verhalten undefiniert.",
+ "",
+ "Es ist auch möglich diese Anweisung für eine feste Zeichenfolge zu",
+ "verwenden, die über den seriellen Anschluss gesendet wird, ohne den Wert",
+ "einer Ganzzahlvariablen in den Text zu interpolieren. In diesem Fall",
+ "fügen Sie einfach diese spezielle Steuerungsfolge nicht ein.",
+ "",
+ "Verwenden Sie ‘\\\\’ für einen zeichengetreuen verkehrten Schrägstrich.",
+ "Zusätzlich zur Steuerungsfolge für die Interpolierung einer Ganzzahl-",
+ "Variablen, sind die folgenden Steuerungszeichen erhältlich:",
+ "",
+ " * \\r -- carriage return Zeilenschaltung",
+ " * \\n -- new line Zeilenwechsel",
+ " * \\f -- form feed Formularvorschub",
+ " * \\b -- backspace Rücksetzen",
+ " * \\xAB -- character with ASCII value 0xAB (hex)",
+ " -- Schriftzeichen mit ASCII-Wert 0xAB (hex)",
+ "",
+ "Der Ausgangszustand des Netzwerks dieser Anweisung ist ‘wahr’, während",
+ "diese Daten überträgt, ansonsten ‘unwahr’. Diese Anweisung benötigt eine",
+ "große Menge des Programmspeichers, insofern sollte sie sparsam verwendet",
+ "werden. Die gegenwärtige Umsetzung ist nicht besonders effizient, aber",
+ "eine bessere würde Änderungen an sämtlichen Ausläufern des Programms",
+ "benötigen.",
+ "",
+ "",
+ "EIN HINWEIS ZUR VERWENDUNG DER MATHEMATIK",
+ "=========================================",
+ "",
+ "Denken Sie daran, dass LDmicro nur 16-Bit mathematische Operationen",
+ "ausführt. Dies bedeutet, dass das Endresultat jeder Berechnung,",
+ "die Sie vornehmen, eine Ganzzahl zwischen -32768 und 32767 sein muss.",
+ "Dies bedeutet auch, dass die Zwischenergebnisse Ihrer Berechnungen alle",
+ "in diesem Bereich liegen müssen.",
+ "",
+ "Wollen wir zum Beispiel annehmen, dass Sie folgendes berechnen möchten",
+ "y = (1/x) * 1200, in der x zwischen 1 und 20 liegt.",
+ "Dann liegt y zwischen 1200 und 60, was in eine 16-Bit Ganzzahl passt,",
+ "so wäre es zumindest theoretisch möglich diese Berechnung auszuführen.",
+ "Es gibt zwei Möglichkeiten, wie Sie dies codieren könnten: Sie können",
+ "die Reziproke (Kehrwert) ausführen and dann multiplizieren:",
+ "",
+ " || {DIV temp :=} ||",
+ " ||---------{ 1 / x }----------||",
+ " || ||",
+ " || {MUL y := } ||",
+ " ||----------{ temp * 1200}----------||",
+ " || ||",
+ "",
+ "Oder Sie könnten einfach die Division in einem Schritt direkt vornehmen.",
+ "",
+ " || {DIV y :=} ||",
+ " ||-----------{ 1200 / x }-----------||",
+ "",
+ "",
+ "Mathematisch sind die zwei äquivalent; aber wenn Sie diese ausprobieren,",
+ "so werden Sie herausfinden, dass die erste ein falsches Ergebnis von",
+ "y = 0 liefert. Dies geschieht, weil die Variable einen Unterlauf",
+ "[= resultatabhängige Kommaverschiebung] ergibt. So sei zum Beispiel x = 3,",
+ "(1 / x) = 0.333, dies ist aber keine Ganzzahl; die Divisionsoperation",
+ "nähert dies, als 'temp = 0'. Dann ist y = temp * 1200 = 0. Im zweiten",
+ "Fall gibt es kein Zwischenergebnis, welches einen Unterlauf [= resultats-",
+ "abhängige Kommaverschiebung] ergibt, somit funktioniert dann alles.",
+ "",
+ "Falls Sie Probleme bei Ihren mathematischen Operationen erkennen,",
+ "dann überprüfen Sie die Zwischenergebnisse auf Unterlauf [eine",
+ "resultatabhängige Kommaverschiebung] (oder auch auf Überlauf, der dann",
+ "im Programm in Umlauf kommt; wie zum Beispiel 32767 + 1 = -32768).",
+ "Wann immer möglich, wählen Sie Einheiten, deren Werte in einem Bereich",
+ "von -100 bis 100 liegen.",
+ "",
+ "Falls Sie eine Variable um einen bestimmten Faktor vergrößern müssen, tun",
+ "Sie dies, indem Sie eine Multiplikation und eine Division verwenden. Um",
+ "zum Beispiel y = 1.8 * x zu vergrößern, berechnen Sie y = (9/5) * x,",
+ "(was dasselbe ist, weil 1,8 = 9/5 ist), und codieren Sie dies als",
+ "y = (9 * x)/5, indem Sie die Multiplikation zuerst ausführen.",
+ "",
+ " || {MUL temp :=} ||",
+ " ||---------{ x * 9 }----------||",
+ " || ||",
+ " || {DIV y :=} ||",
+ " ||-----------{ temp / 5 }-----------||",
+ "",
+ "",
+ "Dies funktioniert mit allen x < (32767 / 9), oder x < 3640. Bei höheren",
+ "Werten würde die Variable ‘temp’ überfließen. Für x gibt es eine",
+ "ähnliche Untergrenze.",
+ "",
+ "",
+ "KODIER-STIL",
+ "===========",
+ "",
+ "Ich gestatte mehrere Spulen in Parallelschaltung in einem einzigen",
+ "Netzwerk unterzubringen. Das bedeutet, sie können ein Netzwerk, wie",
+ "folgt schreiben:",
+ "",
+ " || Xa Ya ||",
+ " 1 ||-------] [--------------( )-------||",
+ " || ||",
+ " || Xb Yb ||",
+ " ||-------] [------+-------( )-------||",
+ " || | ||",
+ " || | Yc ||",
+ " || +-------( )-------||",
+ " || ||",
+ " ",
+ "Anstatt diesem:",
+ "",
+ " || Xa Ya ||",
+ " 1 ||-------] [--------------( )-------||",
+ " || ||",
+ " || ||",
+ " || ||",
+ " || ||",
+ " || Xb Yb ||",
+ " 2 ||-------] [--------------( )-------||",
+ " || ||",
+ " || ||",
+ " || ||",
+ " || ||",
+ " || Xb Yc ||",
+ " 3 ||-------] [--------------( )-------||",
+ " || ||",
+ "",
+ "Rein theoretisch bedeutet das, dass Sie irgendein Programm, als ein",
+ "gigantisches Netzwerk, schreiben könnten. Und es bestünde überhaupt",
+ "keine Notwendigkeit mehrere Netzwerke zu verwenden. In der Praxis ist",
+ "dies aber eine schlechte Idee, denn wenn Netzwerke komplexer werden, so",
+ "werden sie auch schwieriger zu editieren, ohne Löschen und neu Schreiben",
+ "von Anweisungen.",
+ "",
+ "Jedoch, ist es manchmal ein guter Einfall, verwandte Logik in einem",
+ "einzelnen Netzwerk zusammenzufassen. Dies erzeugt einen beinahe",
+ "identischen Code, als ob sie getrennte Netzwerke entworfen hätten, es",
+ "zeigt aber, dass diese Anweisungen (Logik) verwandt ist, wenn man diese",
+ "im Netzwerk-Diagramm betrachtet.",
+ "",
+ " * * *",
+ "",
+ "Im Allgemeinen hält man es für eine schlechte Form, den Code in einer",
+ "solchen Weise zu schreiben, dass sein Ergebnis von einer Folge von",
+ "Netzwerken abhängt. So zum Beispiel ist der folgende Code nicht besonders",
+ "gut, falls ‘xa’ und ‘xb’ jemals ‘wahr’ würden.",
+ "",
+ " || Xa {v := } ||",
+ " 1 ||-------] [--------{ 12 MOV}--||",
+ " || ||",
+ " || Xb {v := } ||",
+ " ||-------] [--------{ 23 MOV}--||",
+ " || ||",
+ " || ||",
+ " || ||",
+ " || ||",
+ " || [v >] Yc ||",
+ " 2 ||------[ 15]-------------( )-------||",
+ " || ||",
+ "",
+ "Ich werde diese Regel brechen und indem ich dies so mache, entwerfe ich",
+ "einen Code-Abschnitt, der erheblich kompakter ist. Hier zum Beispiel,",
+ "zeige ich auf, wie ich eine 4-Bit binäre Größe von ‘xb3:0’ in eine",
+ "Ganzzahl wandeln würde.",
+ "",
+ " || {v := } ||",
+ " 3 ||-----------------------------------{ 0 MOV}--||",
+ " || ||",
+ " || Xb0 {ADD v :=} ||",
+ " ||-------] [------------------{ v + 1 }-----------||",
+ " || ||",
+ " || Xb1 {ADD v :=} ||",
+ " ||-------] [------------------{ v + 2 }-----------||",
+ " || ||",
+ " || Xb2 {ADD v :=} ||",
+ " ||-------] [------------------{ v + 4 }-----------||",
+ " || ||",
+ " || Xb3 {ADD v :=} ||",
+ " ||-------] [------------------{ v + 8 }-----------||",
+ " || ||",
+ "",
+ "Falls die TRANSFER-Anweisung (MOV) an das untere Ende des Netzwerks",
+ "gebracht würde, anstatt auf das obere, so würde der Wert von ‘v’, an",
+ "anderer Stelle im Programm gelesen, gleich Null sein. Das Ergebnis dieses",
+ "Codes hängt daher von der Reihenfolge ab, in welcher die Anweisungen",
+ "ausgewertet werden. Im Hinblick darauf, wie hinderlich es wäre, diesen",
+ "Code auf eine andere Weise zu schreiben, nehme ich dies so hin.",
+ "",
+ "",
+ "BUGS",
+ "====",
+ "",
+ "LDmicro erzeugt keinen sehr effizienten Code; es ist langsam in der",
+ "Ausführung und geht verschwenderisch mit dem Flash- und RAM-Speicher",
+ "um. Trotzdem kann ein mittelgroßer PIC- oder AVR-Prozessor alles, was",
+ "eine kleine SPS kann, somit stört dies mich nicht besonders.",
+ "",
+ "Die maximale Länge der Variabelen-Bezeichnungen (-Namen) ist sehr",
+ "begrenzt. Dies ist so, weil diese so gut in das KOP-Programm (ladder)",
+ "passen. Somit sehe ich keine gute Lösung für diese Angelegenheit.",
+ "",
+ "Falls Ihr Programm zu groß für die Zeit-, Programmspeicher- oder",
+ "Datenspeicher-Beschränkungen des Prozessors ist, den Sie gewählt haben,",
+ "so erhalten Sie keine Fehlermeldung. Es wird einfach irgendwo anders alles",
+ "vermasseln. (Anmerkung: Das AVR STK500 gibt hierzu Fehlermeldungen aus.)",
+ "",
+ "Unsorgfältiges Programmieren bei den Datei Öffnen/Abspeichern-Routinen",
+ "führen wahrscheinlich zu der Möglichkeit eines Absturzes oder es wird",
+ "ein willkürlicher Code erzeugt, der eine beschädigte oder bösartige .ld",
+ "Datei ergibt.",
+ "",
+ "Bitte berichten Sie zusätzliche Bugs oder richten Sie Anfragen für neue",
+ "Programm-Bestandteile an den Autor (in Englisch).",
+ "",
+ "Thanks to:",
+ " * Marcelo Solano, for reporting a UI bug under Win98",
+ " * Serge V. Polubarjev, for not only noticing that RA3:0 on the",
+ " PIC16F628 didn't work but also telling me how to fix it",
+ " * Maxim Ibragimov, for reporting and diagnosing major problems",
+ " with the till-then-untested ATmega16 and ATmega162 targets",
+ " * Bill Kishonti, for reporting that the simulator crashed when the",
+ " ladder logic program divided by zero",
+ " * Mohamed Tayae, for reporting that persistent variables were broken",
+ " on the PIC16F628",
+ " * David Rothwell, for reporting several user interface bugs and a",
+ " problem with the \"Export as Text\" function",
+ "",
+ "Particular thanks to Heinz Ullrich Noell, for this translation (of both",
+ "the manual and the program's user interface) into German.",
+ "",
+ "",
+ "COPYING, AND DISCLAIMER",
+ "=======================",
+ "",
+ "DO NOT USE CODE GENERATED BY LDMICRO IN APPLICATIONS WHERE SOFTWARE",
+ "FAILURE COULD RESULT IN DANGER TO HUMAN LIFE OR DAMAGE TO PROPERTY. THE",
+ "AUTHOR ASSUMES NO LIABILITY FOR ANY DAMAGES RESULTING FROM THE OPERATION",
+ "OF LDMICRO OR CODE GENERATED BY LDMICRO.",
+ "",
+ "This program is free software: you can redistribute it and/or modify it",
+ "under the terms of the GNU General Public License as published by the",
+ "Free Software Foundation, either version 3 of the License, or (at your",
+ "option) any later version.",
+ "",
+ "This program is distributed in the hope that it will be useful, but",
+ "WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY",
+ "or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License",
+ "for more details.",
+ "",
+ "You should have received a copy of the GNU General Public License along",
+ "with this program. If not, see <http://www.gnu.org/licenses/>.",
+ "",
+ "",
+ "Jonathan Westhues",
+ "",
+ "Rijswijk -- Dec 2004",
+ "Waterloo ON -- Jun, Jul 2005",
+ "Cambridge MA -- Sep, Dec 2005",
+ " Feb, Mar 2006",
+ "",
+ "Email: user jwesthues, at host cq.cx",
+ "",
+ "",
+ NULL
+};
+#endif
+
+#ifdef LDLANG_FR
+char *HelpTextFr[] = {
+ "INTRODUCTION",
+ "============",
+ "",
+ "LDmicro génére du code natif pour certains microcontroleurs Microchip",
+ "PIC16F et Atmel AVR. Usuellement les programmes de developpement pour ces",
+ "microcontrolleurs sont écrits dans des langages comme l'assembleur , le",
+ "C ou le Basic. Un programme qui utilise un de ces langages est une suite",
+ "de commandes. Ces programmes sont puissants et adaptés à l'architecture",
+ "des processeurs, qui de façon interne exécutent une liste d'instructions.",
+ "",
+ "Les API (Automates Programmables Industriels, PLC en anglais, SPS en",
+ "allemand) utilisent une autre voie et sont programmés en Langage à",
+ "Contacts (ou LADDER). Un programme simple est représenté comme ceci :",
+ "",
+ "",
+ " || ||",
+ " || Xbutton1 Tdon Rchatter Yred ||",
+ " 1 ||-------]/[---------[TON 1.000 s]-+-------]/[--------------( )-------||",
+ " || | ||",
+ " || Xbutton2 Tdof | ||",
+ " ||-------]/[---------[TOF 2.000 s]-+ ||",
+ " || ||",
+ " || ||",
+ " || ||",
+ " || Rchatter Ton Tnew Rchatter ||",
+ " 2 ||-------]/[---------[TON 1.000 s]----[TOF 1.000 s]---------( )-------||",
+ " || ||",
+ " || ||",
+ " || ||",
+ " ||------[END]---------------------------------------------------------||",
+ " || ||",
+ " || ||",
+ "",
+ "(TON est une tempo travail; TOF est une tempo repos. les commandes --] [-- ",
+ "représentent des Entrées, qui peuvent être des contacts de relais. Les ",
+ "commandes --( )-- sont des Sorties, qui peuvent représenter des bobines de ",
+ "relais. Beaucoup de références de programmes de langage à contacts (LADDER) ",
+ "existent sur Internet et sont à quelques détails près, identiques à ",
+ "l'implémentation représentée ci-dessus.",
+ "",
+ "Un certain nombre de différences apparaissent entre les programmes en",
+ "langage évolués ( C, Basic, Etc..) et les programmes pour API:",
+ "",
+ " * Le programme est représenté dans un format graphique, et non",
+ " comme une liste de commandes en format texte. Beaucoup de personnes",
+ " trouve cela plus facile à comprendre.",
+ "",
+ " * Au niveau de base, le programme apparait comme un diagramme",
+ " de circuit avec des contacts de relais (Entrées) et des bobines",
+ " (Sorties). Ceci est intuitif pour les programmeurs qui connaissent",
+ " la théorie des circuits électriques.",
+ "",
+ " * Le compilateur de langage à contacts vérifie tout ceci lors",
+ " de la compilation. Vous n'avez pas à écrire de code quand une",
+ " Sortie est remplacée et est remise en Entrée ou si une temporisation",
+ " est modifiée, vous n'avez pas non plus à spécifier l'ordre où les",
+ " calculs doivent être effectués. L'outil API (PLC) s'occupe de cela",
+ " pour vous.",
+ "",
+ "",
+ "LDmicro compile le langage à contact (ladder) en code pour PIC16F ou",
+ "AVR. Les processeurs suivants sont supportés:",
+ "",
+ " * PIC16F877",
+ " * PIC16F628",
+ " * PIC16F876 (non testé)",
+ " * PIC16F88 (non testé)",
+ " * PIC16F819 (non testé)",
+ " * PIC16F887 (non testé)",
+ " * PIC16F886 (non testé)",
+ " * ATmega128",
+ " * ATmega64",
+ " * ATmega162 (non testé)",
+ " * ATmega32 (non testé)",
+ " * ATmega16 (non testé)",
+ " * ATmega8 (non testé)",
+ "",
+ "Il doit être facile de supporter d'autres PIC ou AVR, mais je n'est",
+ "aucun moyen pour les tester. Si vous en voulez un en particulier faites",
+ "moi parvenir votre demande et je verrai ce que je peux faire.",
+ "",
+ "En utilisant LDmicro, vous dessinez un diagramme à contacts pour votre",
+ "programme. Vous pouvez simuler le fonctionnement logique en temps réel sur",
+ "votre PC. Quand vous êtes convaincu que le fonctionnement est correct,",
+ "vous pouvez affecter les broches du microcontroleur pour les Entrées et",
+ "Sorties, ensuite vous compilez votre programmeen code AVR ou PIC. Le",
+ "fichier de sortie du compilateur est un fichier .HEX que vous devrez",
+ "mettre dans le microcontroleur en utilisant un programmateur pour PIC",
+ "ou AVR.",
+ "",
+ "",
+ "LDmicro est conçu pour être similaire à la majorité des API commerciaux.",
+ "Il y a quelques exceptions, et une partie des possibilités n'est",
+ "pas standard avec le matériel industriel. Lire attentivement la",
+ "description de chaque instruction même si elle parait familière. Ce",
+ "document considère que vous avez une connaisance de base du langage à",
+ "contact et de la structure des logiciels pour automates programmables.",
+ "Cycle d'exécution : Lecture des Entrées -> Calculs -> Ecriture des Sorties",
+ "",
+ "",
+ "CIBLES ADDITIONNELLES ",
+ "=====================",
+ "",
+ "Il est aussi possible de générer du code ANSI C . Vous pouvez utiliser",
+ "ceci pour n'importe quel processeur dont vous avez un compilateur C,",
+ "mais le runtime est de votre responsabilité. LDmicro gérére uniquement",
+ "le source pour le cycle de l'API. Vous êtes responsable de l'appel de",
+ "chaque séquence du cycle et de l'implémentation de toutes les Entrées",
+ "/ Sorties (Lecture/Ecriture des Entrées digitales, etc ...). Voir les",
+ "commentaires dans le code source pour plus de détails.",
+ "",
+ "Finalement, LDmicro peut générer un code byte indépendant du processeur",
+ "pour une machine virtuelle prévue pour faire fonctionner ce type de code.",
+ "J'ai prévu un exemple simple d'implémentation d'un interpréteur /VM",
+ "écrit en code C le plus portable possible. La cible fonctionne juste sur",
+ "quelques plateformes ou vous pouvez prévoir votre VM. Ceci peut être utile",
+ "pour des applications ou vous pouvez utiliser le languages à contacts",
+ "comme du langage script pour customiser un programme important. Voir",
+ "les commentaires dans l'exemple pour les détails.",
+ "",
+ "",
+ "OPTIONS LIGNE DE COMMANDE",
+ "=========================",
+ "",
+ "LDmicro.exe fonctionne normallement sans options de ligne de commande.",
+ "Vous pouvez faire un raccourci vers le programme et le sauvegarder sur",
+ "l'écran , il suffit alors de faire un double clic pour le faire démarrer",
+ "et vous vous retrouvez ainsi dans l'interface utilisateur.",
+ "",
+ "Si un nom de fichier est passé en ligne de de commande de LDmicro, (ex:",
+ "`ldmicro.exe asd.ld'), alors LDmicro va essayer d'ouvrir `asd.ld', si",
+ "il existe. Une erreur se produira si `asd.ld' n'existe pas. Vous avez",
+ "la possibilité d'associer LDmicro avec les fichiers d'extention .ld.",
+ "Ceci permet à LDmicro de démarrer automatiquement lors d'un double clic",
+ "sur un fichier xxx.ld.",
+ "",
+ "Si les arguments de la ligne de commande sont passés sous la forme:",
+ "`ldmicro.exe /c src.ld dest.hex', LDmicro compilera le programme`src.ld',",
+ "et sauvegardera le fichier compilé sous`dest.hex'. Après compilation",
+ "LDmicro se termine, que la compilation soit correcte ou pas. Aucun",
+ "message n'est affiché sur la console. Ce mode est pratique uniquement",
+ "lorsque vous exécutez LDmicro en ligne de commande.",
+ "",
+ "",
+ "BASES",
+ "=====",
+ "",
+ "Si vous exécutez LDmicro sans arguments de ligne de commande, il démarre",
+ "avec un programme vide. Si vous démarrer avec le nom d'un programme",
+ "langage à contacts (xxx.ld) en ligne de commande, il va essayer de",
+ "charger le programme au démarrage. LDmicro utilise son format interne",
+ "pour le programme , il ne peut pas importer de programmes édités par",
+ "d'autres outils.",
+ "",
+ "Si vous ne chargez pas un programme existant, LDmicro démarre en insérant",
+ "une ligne vide. Vous pouvez ajouter les instructions pour votre programme:",
+ "par exemple ajouter un jeu de contacts (Instruction -> Insérer Contact)",
+ "qui sera nommé `Xnew'. `X' désigne un contact qui peut être lié à une",
+ "broche d'entrée du microcontroleur, vous pouvez affecter la broche pour",
+ "ce contact plus tard après avoir choisi le microcontroleur et renommé",
+ "les contacts. La première lettre indique de quel type de composants il",
+ "s'agit par exemple :",
+ "",
+ " * Xnom -- Relié à une broche d'entrée du microcontroleur",
+ " * Ynom -- Relié à une broche de sortie du microcontroleur",
+ " * Rnom -- `Relais interne': un bit en mémoire",
+ " * Tnom -- Temporisation; Tempo travail, tempo repos, ou totalisatrice",
+ " * Cnom -- Compteur, Compteur ou décompteur",
+ " * Anom -- Un entier lu sur un comvertisseur A/D ",
+ " * nom -- Variable générique (Entier : Integer)",
+ "",
+ "Choisir le reste du nom pour décrire l'utilisation de ce que fait cet",
+ "objet et qui doit être unique dans tout le programme. Un même nom doit",
+ "toujours se référer au même objet dans le programme en entier.Par",
+ "exemple , vous aurez une erreur si vous utilisez une tempo travail",
+ "(TON) appellée TDelai et une tempo repos (TOF) appellée aussi TDelai",
+ "dans le même programme, le comptage effectué par ces tempo utilisera le",
+ "même emplacement en mémoire, mais il est acceptable d'avoir une tempo",
+ "sauvegardée (RTO) Tdelai même nom avec une instruction de RES, dans ce",
+ "cas l'instruction fonctionne avec le même timer.",
+ "",
+ "Les noms de variables peuvent être des lettres, chiffres ou le",
+ "caractère _. Un nom de variable ne doit pas commencer par un chiffre.",
+ "Les noms de variables sont sensibles à la casse (majuscule/minuscules).",
+ "",
+ "Les instructions de manipulation de variables (MOV, ADD, EQU,",
+ "etc.) peuvent travailler avec des variables de n'importe quel nom. Elles",
+ "peuvent avoir accès aux accumulateurs des temporisations ou des",
+ "compteurs. Cela peut quelquefois être très utile, par exemple si vous",
+ "voulez contrôler la valeur d'un compteur ou d'une temporisation dans",
+ "une ligne particulière.",
+ "",
+ "Les variables sont toujours des entiers 16 bits. Leur valeur peut",
+ "donc être comprise entre -32768 et 32767 inclus. Les variables sont",
+ "toujours signées. Vous pouvez les spécifier de façon littérale comme",
+ "des nombres décimaux normaux (0, 1234, -56), vous pouvez aussi les",
+ "spécifier en caractères ASCII ('A', 'z') en mettant le caractère entre",
+ "des guillemets simples. Vous pouvez utiliser un caractère ASCII dans la",
+ "majorité des endroits où vous pouvez utiliser les nombres décimaux.",
+ "",
+ "En bas de l'écran, vous pouvez voir la liste de tous les objets",
+ "utilisés dans votre programme. La liste est automatiquement générée",
+ "à partir du programme. La majorité des objets ne necessitent aucune",
+ "configuration. Seuls : les objets `Xnom', `Ynom', and `Anom' doivent être",
+ "affectés à une broche du micro La première chose à faire est de choisir",
+ "la microcontroleur utilisé : Paramères -> Microcontroleur ensuite vous",
+ "affectez les broches en faisant un double clic dans la liste.",
+ "",
+ "Vous pouvez modifier le programme en insérant ou supprimant des",
+ "instructions. Le curseur clignote dans la programme pour indiquer",
+ "l'instruction courante sélectionnée et le point d'insertion. S'il ne",
+ "clignote pas pressez <Tab> ou cliquer sur une instruction, ou vous",
+ "pouvez insérer une nouvelle instruction à la droite ou à la gauche",
+ "(en série avec), ou au dessous ou au dessus (en parallèle avec) de",
+ "l'instruction sélectionnée. Quelques opérations ne sont pas permises ,",
+ "par exemple aucune instruction permise à droite de la bobine.",
+ "",
+ "Le programme démarre avec uniquement une ligne. Vous pouvez ajouter",
+ "plusieurs lignes en sélectionnant Insertion -> Ligne avant ou après",
+ "dans le menu. Vous pouvez faire un circuit complexe en plaçant plusieurs",
+ "branches en parallèle ou en série avec une ligne, mais il est plus clair",
+ "de faire plusieurs lignes.",
+ "",
+ "Une fois votre programme écrit, vous pouvez le tester par simulation,",
+ "et le compiler dans un fichier HEX pour le microcontroleur de destination.",
+ "",
+ "SIMULATION",
+ "==========",
+ "",
+ "Pour entrer dans la mode simulation choisir Simulation -> Simuler",
+ "ou presser <Ctrl+M> le programme est affiché différemment en mode",
+ "simulation. Les instructions activées sont affichées en rouge vif, les",
+ "instructions qui ne le sont pas sont affichées en grisé. Appuyer sur la",
+ "barre d'espace pour démarrer l'API pour 1 cycle. Pour faire fonctionner",
+ "continuellement en temps réel choisir Simulation ->Démarrer la simulation",
+ "en temps réel ou presser <Ctrl+R> L'affichage du programme est mise à",
+ "jour en temps réel en fonction des changements d'état des entrées.",
+ "",
+ "Vous pouvez valider l'état des entrées du programme en faisant un",
+ "double clic sur l'entrée dans la liste au bas de l'écran, ou sur le",
+ "contact `Xnom' de l'instruction dans le programme, pour avoir le reflet",
+ "automatiquement de la validation d'une entrée dans le programme, il",
+ "faut que le programme soit en cycle.(le démarrer par <Ctrl+R> ou barre",
+ "d'espace pour un seul cycle).",
+ "",
+ "COMPILER EN CODE NATIF",
+ "======================",
+ "",
+ "Le point final est de générer un fichier .HEX qui sera programmé dans le",
+ "microcontroleur que vous avez choisi par Paramètres -> Microcontroleur",
+ "Vous devez affecter les broches d'entrées sorties pour chaque 'Xnom'",
+ "et 'Ynom'. Vous pouvez faire cela en faisant un double clic sur la nom",
+ "de l'objet dans la liste au bas de l'écran. Une boite de dialogue vous",
+ "demande de choisir une des broches non affectées dans la liste.",
+ "",
+ "Vous devez aussi choisir la temps de cycle que voulez utiliser pour",
+ "votre application, vous devez aussi choisir la fréquence d'horloge du",
+ "processeur. Faire Paramètres -> Paramètres MCU dans le menu. En général,",
+ "le temps de cycle peut être laissé à la valeur par défaut (10 ms) qui est",
+ "une bonne valeur pour la majorité des applications. Indiquer la fréquence",
+ "du quartz utilisé (ou du résonateur céramique ou autres..) et cliquer OK.",
+ "",
+ "Maintenant vous pouvez créer le fichier pour intégrer dans le",
+ "microcontroleur. Choisir Compilation -> Compiler, ou compiler sous...",
+ "Si vous avez précédemment compilé votre programme, vous pouvez spécifier",
+ "un nom différent de fichier de sortie. Si votre programme ne comporte",
+ "pas d'erreur (lié à la structure du programme), LDmicro génére un fichier",
+ "IHEX prêt à être programmé dans le chip.",
+ "",
+ "Utilisez votre logiciel et matériel de programmation habituel pour",
+ "charger le fichier HEX dans la microcontroleur. Vérifiez et validez",
+ "les bits de configuration (fuses), pour les processeurs PIC16Fxxx ces",
+ "bits sont inclus dans le fichier HEX, et la majorité des logiciels de",
+ "programmation les valident automatiquement, pour les processeurs AVR ,",
+ "vous devez le faire manuellement.",
+ "",
+ "REFERENCE DES INSTRUCTIONS ",
+ "==========================",
+ "",
+ "> CONTACT, NORMALLEMENT OUVERT Xnom Rnom Ynom",
+ " ----] [---- ----] [---- ----] [----",
+ "",
+ " Si le signal arrivant à cette instruction est FAUX (0) le signal",
+ " de sortie est aussi faux (0), s'il est vrai , il sera aussi vrai",
+ " en sortie si et uniquement si la broche d'Entrée ou de Sortie",
+ " ou de Relais interne est vraie, sinon l'instruction sera fausse.",
+ " Cette instruction peut vérifier l'état d'une broche d'entrée, d'une",
+ " broche de sortie ou d'un relais interne",
+ "",
+ " ",
+ "> CONTACT, NORMALLEMENT FERME Xnom Rnom Ynom",
+ " ----]/[---- ----]/[---- ----]/[----",
+ "",
+ " Si le signal arrivant à cette instruction est FAUX (0) le signal",
+ " de sortie est vrai (1), s'il est vrai , il sera faux en sortie .",
+ " Cette instruction peut vérifier l'état d'une broche d'entrée, d'une",
+ " broche de sortie ou d'un relais interne. Fonctionne en opposition",
+ " par rapport au contact normallement ouvert.",
+ "",
+ "",
+ "> BOBINE, NORMALE Rnom Ynom",
+ " ----( )---- ----( )----",
+ "",
+ " Si le signal arrivant à cette instruction est faux, alors le relais ",
+ " interne ou la broche de sortie est faux (mise à zéro). Si le signal",
+ " arrivant à cette instruction est vrai(1), alors le relais interne ou",
+ " la broche de sortie est validée (mise à 1). Il n'est pas important",
+ " d'affecter une variable à une bobine.",
+ " Cette instruction est placée le plus à droite dans une séquence.",
+ " ",
+ "",
+ "> BOBINE, INVERSE Rnom Ynom",
+ " ----(/)---- ----(/)----",
+ "",
+ " Si le signal arrivant à cette instruction est vrai, alors le relais ",
+ " interne ou la broche de sortie est faux (mise à zéro). Si le signal",
+ " arrivant à cette instruction est faux(0), alors le relais interne ou",
+ " la broche de sortie est validée (mise à 1). Il n'est pas important ",
+ " d'affecter une variable à une bobine.",
+ " Cette instruction est placée le plus à droite dans une séquence.",
+ "",
+ "",
+ "> BOBINE, ACCROCHAGE Rnom Ynom",
+ " ----(S)---- ----(S)----",
+ "",
+ " Si le signal arrivant à cette instruction est vrai, alors le",
+ " relais interne ou la broche de sortie est validée (mise à 1). Cette",
+ " instruction permet de changer l'état d'un relais ou d'une sortie :",
+ " uniquement passe à vrai, ou reste vrai si elle était déjà à 1,",
+ " elle est typiquement utilisée en combinaison avec une Bobine REMISE",
+ " A ZERO.",
+ " Cette instruction est placée le plus à droite dans une séquence.",
+ "",
+ "",
+ "> BOBINE, REMISE A ZERO Rnom Ynom",
+ " ----(R)---- ----(R)----",
+ "",
+ " Si le signal arrivant à cette instruction est vrai, alors le relais ",
+ " interne ou la sortie est mise à zéro (0), si elle était déjà à 0, ",
+ " il n'y a aucun changement, cette instruction change l'état d'une ",
+ " sortie uniquement si elle était à 1, cette instruction fonctionne en ",
+ " combinaison avec l'instruction ci-dessus Bobine à ACCROCHAGE.",
+ " Cette instruction est placée le plus à droite dans une séquence.",
+ "",
+ "",
+ "> TEMPORISATION TRAVAIL Tdon ",
+ " -[TON 1.000 s]-",
+ "",
+ " Quand la signal arrivant à cette instruction passe de faux à vrai",
+ " (0 à 1), le signal de sortie attend 1.000 seconde avant de passer",
+ " à 1. Quand le signal de commande de cette instruction passe ZERO,",
+ " le signal de sortie passe immédiatement à zéro. La tempo est remise",
+ " à zéro à chaque fois que l'entrée repasse à zéro. L'entrée doit être",
+ " maintenue vraie à 1 pendant au moins 1000 millisecondes consécutives",
+ " avant que la sortie ne devienne vraie. le délai est configurable.",
+ "",
+ " La variable `Tnom' compte depuis zéro en unités de temps de scan.",
+ " L'instruction Ton devient vraie en sortie quand la variable du",
+ " compteur est plus grande ou égale au delai fixé. Il est possible",
+ " de manipuler la variable du compteur en dehors, par exemple par une",
+ " instruction MOVE.",
+ "",
+ "",
+ "> TEMPORISATION REPOS Tdoff ",
+ " -[TOF 1.000 s]-",
+ "",
+ " Quand le signal qui arrive à l'instruction passe de l'état vrai",
+ " (1) à l'état faux (0), la sortie attend 1.000 s avant de dévenir",
+ " faux (0) Quand le signal arrivant à l'instruction passe de l'état",
+ " faux à l'état vrai, le signal passe à vrai immédiatement. La",
+ " temporisation est remise à zéro à chaque fois que l'entrée devient",
+ " fausse. L'entrée doit être maintenue à l'état faux pendant au moins",
+ " 1000 ms consécutives avant que la sortie ne passe à l'état faux. La",
+ " temporisation est configurable.",
+ "",
+ " La variable `Tname' compte depuis zéro en unités de temps de scan.",
+ " L'instruction Ton devient vraie en sortie quand la variable du",
+ " compteur est plus grande ou égale au delai fixé. Il est possible",
+ " de manipuler la variable du compteur en dehors, par exemple par une",
+ " instruction MOVE.",
+ "",
+ "",
+ "> TEMPORISATION TOTALISATRICE Trto ",
+ " -[RTO 1.000 s]-",
+ "",
+ " Cette instruction prend en compte le temps que l'entrée a été à l'état",
+ " vrai (1). Si l'entrée a été vraie pendant au moins 1.000s la sortie",
+ " devient vraie (1).L'entrée n'a pas besoin d'être vraie pendant 1000 ms",
+ " consécutives. Si l'entrée est vraie pendant 0.6 seconde puis fausse",
+ " pendant 2.0 secondes et ensuite vraie pendant 0.4 seconde, la sortie",
+ " va devenir vraie. Après être passé à l'état vrai, la sortie reste",
+ " vraie quelque soit la commande de l'instruction. La temporisation",
+ " doit être remise à zéro par une instruction de RES (reset).",
+ "",
+ " La variable `Tnom' compte depuis zéro en unités de temps de scan.",
+ " L'instruction Ton devient vraie en sortie quand la variable du",
+ " compteur est plus grande ou égale au delai fixé. Il est possible",
+ " de manipuler la variable du compteur en dehors, par exemple par une",
+ " instruction MOVE.",
+ "",
+ "",
+ "> RES Remise à Zéro Trto Citems",
+ " ----{RES}---- ----{RES}----",
+ "",
+ " Cette instruction fait un remise à zéro d'une temporisation ou d'un",
+ " compteur. Les tempos TON et TOF sont automatiquement remisent à zéro",
+ " lorsque leurs entrées deviennent respectivement fausses ou vraies,",
+ " RES n'est pas donc pas nécessaire pour ces tempos. Les tempos RTO",
+ " et les compteurs décompteurs CTU / CTD ne sont pas remis à zéro",
+ " automatiquement, il faut donc utiliser cette instruction. Lorsque",
+ " l'entrée est vraie , le compteur ou la temporisation est remis à",
+ " zéro. Si l'entrée reste à zéro, aucune action n'est prise.",
+ " Cette instruction est placée le plus à droite dans une séquence.",
+ "",
+ "",
+ "> FRONT MONTANT _",
+ " --[OSR_/ ]--",
+ "",
+ " La sortie de cette instruction est normallement fausse. Si",
+ " l'instruction d'entrée est vraie pendant ce scan et qu'elle était",
+ " fausse pendant le scan précédent alors la sortie devient vraie. Elle",
+ " génére une impulsion à chaque front montant du signal d'entrée. Cette",
+ " instruction est utile si vous voulez intercepter le front montant",
+ " du signal.",
+ "",
+ "",
+ "> FRONT DESCENDANT _",
+ " --[OSF \\_]--",
+ "",
+ " La sortie de cette instruction est normallement fausse. Si",
+ " l'instruction d'entrée est fausse (0) pendant ce scan et qu'elle",
+ " était vraie (1) pendant le scan précédent alors la sortie devient",
+ " vraie. Elle génére une impulsion à chaque front descendant du signal",
+ " d'entrée. Cette instruction est utile si vous voulez intercepter le",
+ " front descendant d'un signal.",
+ "",
+ "",
+ "> COURT CIRCUIT (SHUNT), CIRCUIT OUVERT",
+ " ----+----+---- ----+ +----",
+ "",
+ " Une instruction shunt donne en sortie une condition qui est toujours ",
+ " égale à la condition d'entrée. Une instruction Circuit Ouvert donne ",
+ " toujours une valeur fausse en sortie.",
+ " Ces instructions sont en général utilisées en phase de test.",
+ "",
+ "",
+ "> RELAIS DE CONTROLE MAITRE",
+ " -{MASTER RLY}-",
+ "",
+ " Par défaut, la condition d'entrée d'une ligne est toujours vraie. Si",
+ " une instruction Relais de contrôle maitre est exécutée avec une",
+ " valeur d'entrée fausse, alors toutes les lignes suivantes deviendront",
+ " fausses. Ceci va continuer jusqu'à la rencontre de la prochaine",
+ " instruction relais de contrôle maitre qui annule l'instruction de",
+ " départ. Ces instructions doivent toujours être utilisées par paires:",
+ " une pour commencer (qui peut être sous condition) qui commence la",
+ " partie déactivée et une pour la terminer.",
+ "",
+ "",
+ "> MOUVOIR {destvar := } {Tret := }",
+ " -{ 123 MOV}- -{ srcvar MOV}-",
+ "",
+ " Lorsque l'entrée de cette instruction est vraie, elle va mettre la",
+ " variable de destination à une valeur égale à la variable source ou à",
+ " la constante source. Quand l'entrée de cette instruction est fausse",
+ " rien ne se passe. Vous pouvez affecter n'importe quelle variable",
+ " à une instruction de déplacement, ceci inclu l'état de variables",
+ " compteurs ou temporisateurs qui se distinguent par l'entête T ou",
+ " C. Par exemple mettre 0 dans Tsauvegardé équivaut à faire une RES",
+ " de la temporisation. Cette instruction doit être complétement à",
+ " droite dans une séquence.",
+ "",
+ "",
+ "> OPERATIONS ARITHMETIQUES {ADD kay :=} {SUB Ccnt :=}",
+ " -{ 'a' + 10 }- -{ Ccnt - 10 }-",
+ "",
+ "> {MUL dest :=} {DIV dv := }",
+ " -{ var * -990 }- -{ dv / -10000}-",
+ "",
+ " Quand l'entrée de cette instruction est vraie, elle place en",
+ " destination la variable égale à l'expression calculée. Les opérandes",
+ " peuvent être des variables (en incluant les variables compteurs et",
+ " tempos) ou des constantes. Ces instructions utilisent des valeurs 16",
+ " bits signées. Il faut se souvenir que le résultat est évalué à chaque",
+ " cycle tant que la condition d'entrée est vraie. Si vous incrémentez",
+ " ou décrémentez une variable (si la variable de destination est",
+ " aussi une des opérandes), le résultat ne sera pas celui escompté,",
+ " il faut utiliser typiquement un front montant ou descendant de la",
+ " condition d'entrée qui ne sera évalué qu'une seule fois. La valeur",
+ " est tronquée à la valeur entière. Cette instruction doit être",
+ " complétement à droite dans une séquence.",
+ "",
+ "",
+ "> COMPARER [var ==] [var >] [1 >=]",
+ " -[ var2 ]- -[ 1 ]- -[ Ton]-",
+ "",
+ "> [var /=] [-4 < ] [1 <=]",
+ " -[ var2 ]- -[ vartwo]- -[ Cup]-",
+ "",
+ " Si l'entrée de cette instruction est fausse alors la sortie est",
+ " fausse. Si l'entrée est vraie, alors la sortie sera vraie si et",
+ " uniquement si la condition de sortie est vraie. Cette instruction",
+ " est utilisée pour comparer (Egalité, plus grand que,plus grand ou",
+ " égal à, inégal, plus petit que, plus petit ou égal à) une variable à",
+ " une autre variable, ou pour comparer une variable avec une constante",
+ " 16 bits signée.",
+ "",
+ "",
+ "> COMPTEUR DECOMPTEUR Cnom Cnom",
+ " --[CTU >=5]-- --[CTD >=5]--",
+ "",
+ " Un compteur incrémente ( Compteur CTU, count up) ou décrémente",
+ " (Décompteur CTD, count down) une variable à chaque front montant de",
+ " la ligne en condition d'entrée (CAD quand la signal passe de l'état",
+ " 0 à l'état 1. La condition de sortie du compteur est vraie si la",
+ " variable du compteur est égale ou plus grande que 5 (dans l'exemple),",
+ " et faux sinon. La condition de sortie de la ligne peut être vraie,",
+ " même si la condition d'entrée est fausse, cela dépend uniquement de la",
+ " valeur de la variable du compteur. Vous pouvez avoir un compteur ou",
+ " un décompteur avec le même nom, qui vont incréménter ou decrémenter",
+ " une variable. L'instruction Remise à Zéro permet de resetter un",
+ " compteur (remettre à zéro), il est possible de modifier par des",
+ " opérations les variables des compteurs décompteurs.",
+ "",
+ "",
+ "> COMPTEUR CYCLIQUE Cnom",
+ " --{CTC 0:7}--",
+ "",
+ " Un compteur cyclique fonctionne comme un compteur normal",
+ " CTU, exception faite, lorsque le compteur arrive à sa",
+ " limite supérieure, la variable du compteur revient à 0. dans",
+ " l'exemple la valeur du compteur évolue de la façon suivante :",
+ " 0,1,2,4,5,6,7,0,1,2,3,4,5,6,7,0,1,3,4,5,etc. Ceci est très pratique",
+ " en conbinaison avec des intructions conditionnelles sur la variable",
+ " Cnom. On peut utiliser ceci comme un séquenceur, l'horloge du compteur",
+ " CTC est validée par la condition d'entrée associée à une instruction",
+ " de front montant.",
+ " Cette instruction doit être complétement à droite dans une séquence.",
+ " ",
+ "",
+ "> REGISTRE A DECALAGE {SHIFT REG }",
+ " -{ reg0..3 }-",
+ "",
+ " Un registre à décalage est associé avec un jeu de variables. Le",
+ " registre à décalage de l'exemple donné est associé avec les",
+ " variables`reg0', `reg1', `reg2', and `reg3'. L'entrée du registre à",
+ " décalage est `reg0'. A chaque front montant de la condition d'entrée",
+ " de la ligne, le registre à décalage va décaler d'une position à",
+ " droite. Ce qui donne `reg3 := reg2', `reg2 := reg1'. et `reg1 :=",
+ " reg0'.`reg0' est à gauche sans changement. Un registre à décalage",
+ " de plusieurs éléments peut consommer beaucoup de place en mémoire.",
+ " Cette instruction doit être complétement à droite dans une séquence.",
+ "",
+ "",
+ "> TABLEAU INDEXE {dest := }",
+ " -{ LUT[i] }-",
+ "",
+ " Un tableau indexé et un groupe ordonné de n valeurs Quand la condition",
+ " d'entrée est vraie, la variable entière `dest' est mise à la valeur",
+ " correspondand à l'index i du tableau. L'index est compris entre 0 et",
+ " (n-1). Le comportement de cette instruction est indéfini si l'index",
+ " est en dehors du tableau",
+ " Cette instruction doit être complétement à droite dans une séquence.",
+ "",
+ "",
+ "> TABLEAU ELEMENTS LINEAIRES {yvar := }",
+ " -{ PWL[xvar] }-",
+ "",
+ " C'est une bonne méthode pour évaluer de façon approximative une",
+ " fonction compliquée ou une courbe. Très pratique par exemple pour",
+ " appliquer une courbe de calibration pour linéariser tension de sortie",
+ " d'un capteur dans une unité convenable.",
+ "",
+ " Supposez que vous essayez de faire une fonction pour convertir une",
+ " variable d'entrée entière, x, en une variable de sortie entière, y,",
+ " vous connaissez la fonction en différents points, par exemple vous",
+ " connaissez :",
+ "",
+ " f(0) = 2",
+ " f(5) = 10",
+ " f(10) = 50",
+ " f(100) = 100",
+ "",
+ " Ceci donne les points",
+ "",
+ " (x0, y0) = ( 0, 2)",
+ " (x1, y1) = ( 5, 10)",
+ " (x2, y2) = ( 10, 50)",
+ " (x3, y3) = (100, 100)",
+ "",
+ " liés à cette courbe. Vous pouvez entrer ces 4 points dans un",
+ " tableau associé à l'instruction tableau d'éléments linéaires. Cette",
+ " instruction regarde la valeur de xvar et fixe la valeur de yvar",
+ " correspondante. Par exemple si vous mettez xvar = 10 , l'instruction",
+ " validera yvar = 50.",
+ "",
+ " Si vous mettez une instruction avec une valeur xvar entre deux valeurs",
+ " de x du tableau (et par conséquence aussi de yvar). Une moyenne",
+ " proportionnelle entre les deux valeurs , précédente et suivante de",
+ " xvar et de la valeur liée yvar, est effectuée. Par exemple xvar =",
+ " 55 donne en sortie yvar = 75 Les deux points xvar (10.50) et yvar",
+ " (50,75) , 55 est la moyenne entre 10 et 100 et 75 est la moyenne",
+ " entre 50 et 100, donc (55,75) sont liés ensemble par une ligne de",
+ " connection qui connecte ces deux points.",
+ "",
+ " Ces points doivent être spécifiés dans l'ordre ascendant des",
+ " coordonnées x. Il peut être impossible de faire certaines opérations",
+ " mathématiques nécessaires pour certains tableaux, utilisant des",
+ " entiers 16 bits. Dans ce LDmicro va provoquer une alarme. Ce tableau",
+ " va provoquer une erreur :",
+ "",
+ " (x0, y0) = ( 0, 0)",
+ " (x1, y1) = (300, 300)",
+ "",
+ " Vous pouvez supprimer ces erreurs en diminuant l'écart entre les",
+ " points du tableau, par exemple ce tableau est équivalent à celui ci",
+ " dessus , mais ne provoque pas d'erreur:",
+ "",
+ " (x0, y0) = ( 0, 0)",
+ " (x1, y1) = (150, 150)",
+ " (x2, y2) = (300, 300)",
+ "",
+ " Il n'est pratiquement jamais nécessaire d'utiliser plus de 5 ou",
+ " 6 points. Ajouter des points augmente la taille du code et diminue",
+ " sa vitesse d'exécution. Le comportement, si vous passez une valeur",
+ " à xvar plus grande que la plus grande valeur du tableau , ou plus",
+ " petit que la plus petite valeur, est indéfini.",
+ " Cette instruction doit être complétement à droite dans une séquence.",
+ "",
+ "",
+ "> LECTURE CONVERTISSEUR A/D Anom",
+ " --{READ ADC}--",
+ "",
+ " LDmicro peut générer du code pour utiliser les convertisseurs A/D",
+ " contenus dans certains microcontroleurs. Si la condition d'entrée",
+ " de l'instruction est vraie, alors une acquisition du convertisseur",
+ " A/D est éffectuée et stockée dans la variable Anom. Cette variable",
+ " peut être par la suite traitée comme les autres variables par les",
+ " différentes opérations arithmétiques ou autres. Vous devez affecter",
+ " une broche du micro à la variable Anom de la même façon que pour",
+ " les entrées et sorties digitales par un double clic dans la list",
+ " affichée au bas de l'écran. Si la condition d'entrée de la séquence",
+ " est fausse la variable Anom reste inchangée.",
+ "",
+ " Pour tous les circuits supportés actuellement, 0 volt en entrée",
+ " correspond à une lecture ADC de 0, et une valeur égale à VDD (la",
+ " tension d'alimentation ) correspond à une lecture ADC de 1023. Si",
+ " vous utilisez un circuit AVR, vous devez connecter Aref à VDD.",
+ "",
+ " Vous pouvez utiliser les opérations arithmétiques pour mettre à ",
+ " l'échelle les lectures effectuées dans l'unité qui vous est la plus ",
+ " appropriée. Mais souvenez vous que tous les calculs sont faits en ",
+ " utilisant les entiers.",
+ "",
+ " En général, toutes les broches ne sont pas utilisables pour les ",
+ " lecture de convertisseur A/D. Le logiciel ne vous permet pas ",
+ " d'affecter une broche non A/D pour une entrée convertisseur.",
+ " Cette instruction doit être complétement à droite dans une séquence.",
+ "",
+ "",
+ "> FIXER RAPPORT CYCLE PWM duty_cycle",
+ " -{PWM 32.8 kHz}-",
+ "",
+ " LDmicro peut générer du code pour utiliser les périphériques PWM",
+ " contenus dans certains microcontroleurs. Si la condition d'entrée",
+ " de cette instruction est vraie, le rapport de cycle du périphérique",
+ " PWM va être fixé à la valeur de la variable Rapport de cycle PWM.",
+ " Le rapport de cycle est un nombre compris entre 0 (toujours au",
+ " niveau bas) et 100 (toujours au niveau haut). Si vous connaissez la",
+ " manière dont les périphériques fonctionnent vous noterez que LDmicro",
+ " met automatiquement à l'échelle la variable du rapport de cycle en",
+ " pourcentage de la période d'horloge PWM.",
+ "",
+ " Vous pouvez spécifier la fréquence de sortie PWM, en Hertz. Le",
+ " fréquence que vous spécifiez peut ne pas être exactement accomplie, en",
+ " fonction des divisions de la fréquence d'horloge du microcontroleur,",
+ " LDmicro va choisir une fréquence approchée. Si l'erreur est trop",
+ " importante, il vous avertit.Les vitesses rapides sont au détriment",
+ " de la résolution. Cette instruction doit être complétement à droite",
+ " dans une séquence.",
+ "",
+ " Le runtime du language à contacts consomme un timers (du micro) pour",
+ " le temps de cycle, ce qui fait que le PWM est uniquement possible",
+ " avec des microcontroleurs ayant au moins deux timers utilisables.",
+ " PWM utilise CCP2 (pas CCP1) sur les PIC16F et OC2(pas OC1) sur les",
+ " Atmel AVR.",
+ "",
+ "> METTRE PERSISTANT saved_var",
+ " --{PERSIST}--",
+ "",
+ " Quand la condition d'entrée de cette instruction est vraie, la",
+ " variable entière spécifiée va être automatiquement sauvegardée en",
+ " EEPROM, ce qui fait que cette valeur persiste même après une coupure",
+ " de l'alimentation du micro. Il n'y a pas à spécifier ou elle doit",
+ " être sauvegardée en EEPROM, ceci est fait automatiquement, jusqu'a",
+ " ce quelle change à nouveau. La variable est automatiquement chargée",
+ " à partir de l'EEPROM suite à un reset à la mise sous tension.",
+ "",
+ " Si une variables, mise persistante, change fréquemment, l'EEPROM de",
+ " votre micro peut être détruite très rapidement, Le nombre de cycles",
+ " d'écriture dans l'EEPROM est limité à environ 100 000 cycles Quand",
+ " la condition est fausse, rien n'apparait. Cette instruction doit",
+ " être complétement à droite dans une séquence.",
+ "",
+ "",
+ "> RECEPTION UART (SERIE) var",
+ " --{UART RECV}--",
+ "",
+ " LDmicro peut générer du code pour utiliser l'UART, existant dans",
+ " certains microcontroleurs. Sur les AVR, avec de multiples UART,",
+ " uniquement l'UART1 est utilisable (pas l'UART0). Configurer la",
+ " vitesse en utilisant -> Paramètres -> Paramètres MCU. Toutes les",
+ " vitesses de liaison ne sont pas utilisables avec tous les quartz de",
+ " toutyes les fréquences. Ldmicro vous avertit dans ce cas.",
+ "",
+ " Si la condition d'entrée de cette instruction est fausse, rien ne se",
+ " passe. Si la condition d'entrée est vraie, elle essaie de recevoir",
+ " un caractère en provenance de l'UART. Si aucun caractère n'est lu",
+ " alors la condition de sortie devient fausse. Si un caractère est",
+ " lu la valeur ASCII est stockée dans 'var' et la condition de sortie",
+ " est vraie pour un seul cycle API.",
+ "",
+ "",
+ "> EMMISION UART (SERIE) var",
+ " --{UART SEND}--",
+ "",
+ " LDmicro peut générer du code pour utiliser l'UART, existant dans ",
+ " certains microcontroleurs. Sur les AVR, avec de multiples UART, ",
+ " uniquement l'UART1 est utilisable (pas l'UART0). Configurer la ",
+ " vitesse en utilisant -> Paramètres -> Paramètres MCU. Toutes les ",
+ " vitesses de liaison ne sont pas utilisables avec tous les quartz ",
+ " de toutyes les fréquences. Ldmicro vous avertit dans ce cas.",
+ "",
+ " Si la condition d'entrée de cette instruction est fausse, rien ne",
+ " se passe. Si la condition d'entrée est vraie alors cette instruction",
+ " écrit un seul caractère vers l'UART. La valeur ASCII du caractère à",
+ " transmettre doit avoir été stocké dans 'var' par avance. La condition",
+ " de sortie de la séquence est vraie, si l'UART est occupée (en cours",
+ " de transmission d'un caractère), et fausse sinon.",
+ "",
+ " Rappelez vous que les caractères mettent un certain temps pour être",
+ " transmis. Vérifiez la condition de sortie de cette instruction pour",
+ " vous assurer que le premier caractère à bien été transmis, avant",
+ " d'essayer d'envoyer un second caractère, ou utiliser une temporisation",
+ " pour insérer un délai entre caractères; Vous devez uniquement vérifier",
+ " que la condition d'entrée est vraie (essayez de transmettre un",
+ " caractère) quand la condition de sortie est fausse(UART non occuppée).",
+ "",
+ " Regardez l'instruction Chaine formattée(juste après) avant d'utiliser",
+ " cette instruction, elle est plus simple à utiliser, et dans la",
+ " majorité des cas, est capable de faire ce dont on a besoin.",
+ "",
+ "",
+ "> CHAINE FORMATTEE SUR UART var",
+ " -{\"Pression: \\3\\r\\n\"}-",
+ "",
+ " LDmicro peut générer du code pour utiliser l'UART, existant dans ",
+ " certains microcontroleurs. Sur les AVR, avec de multiples UART, ",
+ " uniquement l'UART1 est utilisable (pas l'UART0). Configurer la ",
+ " vitesse en utilisant -> Paramètres -> Paramètres MCU. Toutes les ",
+ " vitesses de liaison ne sont pas utilisables avec tous les quartz ",
+ " de toutyes les fréquences. Ldmicro vous avertit dans ce cas.",
+ "",
+ " Quand la condition d'entrée de cette instruction passe de faux à vrai,",
+ " elle commence à envoyer une chaine compléte vers le port série. Si",
+ " la chaine comporte la séquence spéciale '3', alors cette séquence",
+ " va être remplacée par la valeur de 'var', qui est automatiquement",
+ " converti en une chaine. La variable va être formattée pour prendre",
+ " exactement trois caractères; par exemple si var = 35, la chaine",
+ " exacte qui va être \"imprimée\" sera 'Pression: 35\\r\\n' (notez les",
+ " espaces supplémentaires). Si au lieu de cela var = 1432 , la sortie",
+ " est indéfinie parceque 1432 comporte plus de 3 digits. Dans ce cas",
+ " vous devez nécessairement utiliser '\\4' à la place.",
+ "",
+ " Si la variable peut être négative, alors utilisez '\\-3d' (ou `\\-4d'",
+ " etc.) à la place. Ceci oblige LDmicro à imprimer un espace d'entête",
+ " pour les nombres positifs et un signe moins d'entête pour les chiffres",
+ " négatifs.",
+ "",
+ " Si de multiples instructions de chaines formattées sont activées au",
+ " même moment (ou si une est activée avant de finir la précédente)",
+ " ou si ces instructions sont imbriquées avec des instructions TX",
+ " (transmission), le comportement est indéfini.",
+ "",
+ " Il est aussi possible d'utiliser cette instruction pour sortie une",
+ " chaine fixe, sans l'intervention d'une variable en valeur entière",
+ " dans le texte qui est envoyée sur la ligne série. Dans ce cas,",
+ " simplement ne pas inclure de séquence spéciale Escape.",
+ "",
+ " Utiliser `\\\\' pour l'anti-slash. en addition à une séquence escape ",
+ " pour intervenir sue une variables entière, les caractères de ",
+ " contrôles suivants sont utilisables :",
+ " ",
+ " * \\r -- retour en début de ligne",
+ " * \\n -- nouvelle ligne",
+ " * \\f -- saut de page",
+ " * \\b -- retour arrière",
+ " * \\xAB -- caractère avec valeur ASCII 0xAB (hex)",
+ "",
+ " La condition de sortie de cette instruction est vraie quand elle",
+ " transmet des données, sinon elle est fausse. Cette instruction",
+ " consomme une grande quantité de mémoire, elle doit être utilisée",
+ " avec modération. L'implémentation présente n'est pas efficace, mais",
+ " une meilleure implémentation demanderait une modification de tout",
+ " le reste.",
+ "",
+ "NOTE CONCERNANT LES MATHS",
+ "=========================",
+ "",
+ "Souvenez vous que LDmicro travaille uniquement en mathématiques entiers",
+ "16 bits. Ce qui fait que le résultat final de même que tous les calculs",
+ "mêmes intermédiaires seront compris entre -32768 et 32767.",
+ "",
+ "Par exemple, si vous voulez calculer y = (1/x)*1200,ou x est compris",
+ "entre 1 et 20, ce qui donne un résultat entre 1200 et 60,le résultat est",
+ "bien à l'intérieur d'un entier 16 bits, il doit donc être théoriquement",
+ "possible de faire le calcul. Nous pouvons faire le calcul de deux façons",
+ "d'abord faire 1/x et ensuite la multiplication:",
+ "",
+ " || {DIV temp :=} ||",
+ " ||---------{ 1 / x }----------||",
+ " || ||",
+ " || {MUL y := } ||",
+ " ||----------{ temp * 1200}----------||",
+ " || ||",
+ "",
+ "Ou uniquement faire simplement la division en une seule ligne :",
+ "",
+ " || {DIV y :=} ||",
+ " ||-----------{ 1200 / x }-----------||",
+ "",
+ "Mathématiquement c'est identique, la première donne y = 0 , c'est à dire",
+ "une mauvais résultat, si nous prenons par exemple x = 3 , 1/x = 0.333 mais",
+ "comme il s'agit d'un entier, la valeur pour Temp est de 0 et 0*1200 = 0 ",
+ "donc résultat faux.Dans le deuxième cas, il n'y a pas de résultat ",
+ "intermédiaire et le résultat est correct dans tous les cas.",
+ "",
+ "Si vous trouvez un problème avec vos calculs mathématiques, vérifiez les",
+ "résultats intermédiaires, si il n'y a pas de dépassement de capacités par",
+ "rapports aux valeurs entières. (par exemple 32767 + 1 = -32768). Quand",
+ "cela est possible essayer de choisir des valeurs entre -100 et 100.",
+ "",
+ "Vous pouvez utiliser un certain facteur de multiplication ou division pour ",
+ "mettre à l'echelle les variables lors de calculs par exemple : pour mettre",
+ "mettre à l'echelle y = 1.8*x , il est possible de faire y =(9/5)*x ",
+ "(9/5 = 1.8) et coder ainsi y = (9*x)/5 en faisant d'abord la multiplication",
+ "",
+ " || {MUL temp :=} ||",
+ " ||---------{ x * 9 }----------||",
+ " || ||",
+ " || {DIV y :=} ||",
+ " ||-----------{ temp / 5 }-----------||",
+ "",
+ "Ceci fonctionne tant que x < (32767 / 9), or x < 3640. Pour les grandes ",
+ "valeurs de x,la variable `temp' va se mettre en dépassement. Ceci est ",
+ "similaire vers la limite basse de x.",
+ "",
+ "",
+ "STYLE DE CODIFICATION",
+ "=====================",
+ "",
+ "Il est permis d'avoir plusieurs bobines en parallèle, contrôlées par",
+ "une simple ligne comme ci-dessous :",
+ "",
+ " || Xa Ya ||",
+ " 1 ||-------] [--------------( )-------||",
+ " || ||",
+ " || Xb Yb ||",
+ " ||-------] [------+-------( )-------||",
+ " || | ||",
+ " || | Yc ||",
+ " || +-------( )-------||",
+ " || ||",
+ "",
+ "à la place de ceci :",
+ "",
+ " || Xa Ya ||",
+ " 1 ||-------] [--------------( )-------||",
+ " || ||",
+ " || ||",
+ " || ||",
+ " || ||",
+ " || Xb Yb ||",
+ " 2 ||-------] [--------------( )-------||",
+ " || ||",
+ " || ||",
+ " || ||",
+ " || ||",
+ " || Xb Yc ||",
+ " 3 ||-------] [--------------( )-------||",
+ " || ||",
+ "",
+ "Il est permis théoriquement d'écrire un programme avec une séquence très",
+ "importante et de ne pas utiliser plusieurs lignes pour la faire. En",
+ "pratique c'est une mauvaise idée, à cause de la compléxité que cela",
+ "peut engendrer et plus difficile à éditer sans effacer et redessiner un",
+ "certain nombre d'éléments de logique.",
+ "",
+ "Néanmoins, c'est une bonne idée de regrouper différents éléments d'un bloc",
+ "logique dans une seule séquence. Le code généré est identique dans les",
+ "deux cas, et vous pouvez voir ce que fait la séquence dans le diagramme",
+ "à contacts.",
+ "",
+ " * * *",
+ "",
+ "En général, il est considéré comme mauvais d'écrire du code dont la",
+ "sortie dépend de l'ordre d'exécution. Exemple : ce code n'est pas très",
+ "bon lorsque xa et xb sont vrai en même temps :",
+ "",
+ " || Xa {v := } ||",
+ " 1 ||-------] [--------{ 12 MOV}--||",
+ " || ||",
+ " || Xb {v := } ||",
+ " ||-------] [--------{ 23 MOV}--||",
+ " || ||",
+ " || ||",
+ " || ||",
+ " || ||",
+ " || [v >] Yc ||",
+ " 2 ||------[ 15]-------------( )-------||",
+ " || ||",
+ "",
+ "Ci-dessous un exemple pour convertir 4 bits Xb3:0 en un entier :",
+ "",
+ " || {v := } ||",
+ " 3 ||-----------------------------------{ 0 MOV}--||",
+ " || ||",
+ " || Xb0 {ADD v :=} ||",
+ " ||-------] [------------------{ v + 1 }-----------||",
+ " || ||",
+ " || Xb1 {ADD v :=} ||",
+ " ||-------] [------------------{ v + 2 }-----------||",
+ " || ||",
+ " || Xb2 {ADD v :=} ||",
+ " ||-------] [------------------{ v + 4 }-----------||",
+ " || ||",
+ " || Xb3 {ADD v :=} ||",
+ " ||-------] [------------------{ v + 8 }-----------||",
+ " || ||",
+ "",
+ "Si l'instruction MOV est déplacée en dessous des instructions ADD, la",
+ "valeur de la variable v, quand elle est lue autrepart dans le programme,",
+ "serait toujours 0. La sortie du code dépend alors de l'ordre d'évaluations",
+ "des instructions. Ce serait possible de modifier ce code pour éviter cela,",
+ "mais le code deviendrait très encombrant.",
+ "",
+ "DEFAUTS",
+ "=======",
+ "",
+ "LDmicro ne génére pas un code très efficace; il est lent à exécuter et",
+ "il est gourmand en Flash et RAM. Un PIC milieu de gamme ou un AVR peut",
+ "tout de même faire ce qu'un petit automate peut faire.",
+ "",
+ "La longueur maximum des noms de variables est très limitée, ceci pour",
+ "être intégrée correctement dans le diagramme logique, je ne vois pas de",
+ "solution satisfaisante pour solutionner ce problème.",
+ "",
+ "Si votre programme est trop important, vitesse exécution, mémoire",
+ "programme ou contraintes de mémoire de données pour le processeur que vous",
+ "avez choisi, il n'indiquera probablement pas d'erreur. Il se blocquera",
+ "simplement quelque part.",
+ "",
+ "Si vous êtes programmeur négligent dans les sauvegardes et les",
+ "chargements, il est possible qu'un crash se produise ou exécute un code",
+ "arbitraire corrompu ou un mauvais fichier .ld .",
+ "",
+ "SVP, faire un rapport sur les bogues et les demandes de modifications.",
+ "",
+ "Thanks to:",
+ " * Marcelo Solano, for reporting a UI bug under Win98",
+ " * Serge V. Polubarjev, for not only noticing that RA3:0 on the",
+ " PIC16F628 didn't work but also telling me how to fix it",
+ " * Maxim Ibragimov, for reporting and diagnosing major problems",
+ " with the till-then-untested ATmega16 and ATmega162 targets",
+ " * Bill Kishonti, for reporting that the simulator crashed when the",
+ " ladder logic program divided by zero",
+ " * Mohamed Tayae, for reporting that persistent variables were broken",
+ " on the PIC16F628",
+ " * David Rothwell, for reporting several user interface bugs and a",
+ " problem with the \"Export as Text\" function",
+ "",
+ "Particular thanks to Marcel Vaufleury, for this translation (of both",
+ "the manual and the program's user interface) into French.",
+ "",
+ "",
+ "COPYING, AND DISCLAIMER",
+ "=======================",
+ "",
+ "DO NOT USE CODE GENERATED BY LDMICRO IN APPLICATIONS WHERE SOFTWARE",
+ "FAILURE COULD RESULT IN DANGER TO HUMAN LIFE OR DAMAGE TO PROPERTY. THE",
+ "AUTHOR ASSUMES NO LIABILITY FOR ANY DAMAGES RESULTING FROM THE OPERATION",
+ "OF LDMICRO OR CODE GENERATED BY LDMICRO.",
+ "",
+ "This program is free software: you can redistribute it and/or modify it",
+ "under the terms of the GNU General Public License as published by the",
+ "Free Software Foundation, either version 3 of the License, or (at your",
+ "option) any later version.",
+ "",
+ "This program is distributed in the hope that it will be useful, but",
+ "WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY",
+ "or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License",
+ "for more details.",
+ "",
+ "You should have received a copy of the GNU General Public License along",
+ "with this program. If not, see <http://www.gnu.org/licenses/>.",
+ "",
+ "",
+ "Jonathan Westhues",
+ "",
+ "Rijswijk -- Dec 2004",
+ "Waterloo ON -- Jun, Jul 2005",
+ "Cambridge MA -- Sep, Dec 2005",
+ " Feb, Mar 2006",
+ "",
+ "Email: user jwesthues, at host cq.cx",
+ "",
+ "",
+ NULL
+};
+#endif
+
+#ifdef LDLANG_TR
+char *HelpTextTr[] = {
+ "",
+ "KULLANIM KİTAPÇIĞI",
+ "==================",
+ "LDMicro desteklenen MicroChip PIC16 ve Atmel AVR mikrokontrolcüler için ",
+ "gerekli kodu üretir. Bu iş için kullanılabilecek değişik programlar vardır.",
+ "Örneğin BASIC, C, assembler gibi. Bu programlar kendi dillerinde yazılmış",
+ "programları işlemcilerde çalışabilecek dosyalar haline getirirler.",
+ "",
+ "PLC'de kullanılan dillerden biri ladder diyagramıdır. Aşağıda LDMicro ile",
+ "yazılmış basit bir program görülmektedir.",
+ "",
+ " || ||",
+ " || Xbutton1 Tdon Rchatter Yred ||",
+ " 1 ||-------]/[---------[TON 1.000 s]-+-------]/[--------------( )-------||",
+ " || | ||",
+ " || Xbutton2 Tdof | ||",
+ " ||-------]/[---------[TOF 2.000 s]-+ ||",
+ " || ||",
+ " || ||",
+ " || ||",
+ " || Rchatter Ton Tnew Rchatter ||",
+ " 2 ||-------]/[---------[TON 1.000 s]----[TOF 1.000 s]---------( )-------||",
+ " || ||",
+ " || ||",
+ " || ||",
+ " ||------[END]---------------------------------------------------------||",
+ " || ||",
+ " || ||",
+ "",
+ "(TON=turn-on gecikme; TOF-turn-off gecikme. --] [-- girişler, diğer bir ",
+ "deyişle kontaklardır. --( )-- ise çıkışlardır. Bunlar bir rölenin bobini ",
+ "gibi davranırlar. Ladder diyagramı ile ilgili bol miktarda kaynak internet",
+ "üzerinde bulunmaktadır. Burada LDMicro'ya has özelliklerden bahsedeceğiz.",
+ "",
+ "LDmicro ladder diyagramını PIC16 veya AVR koduna çevirir. Aşağıda desteklenen",
+ "işlemcilerin listesi bulunmaktadır:",
+ " * PIC16F877",
+ " * PIC16F628",
+ " * PIC16F876 (denenmedi)",
+ " * PIC16F88 (denenmedi)",
+ " * PIC16F819 (denenmedi)",
+ " * PIC16F887 (denenmedi)",
+ " * PIC16F886 (denenmedi)",
+ " * ATmega128",
+ " * ATmega64",
+ " * ATmega162 (denenmedi)",
+ " * ATmega32 (denenmedi)",
+ " * ATmega16 (denenmedi)",
+ " * ATmega8 (denenmedi)",
+ "",
+ "Aslında daha fazla PIC16 ve AVR işlemci desteklenebilir. Ancak test ettiklerim",
+ "ve desteklediğini düşündüklerimi yazdım. Örneğin PIC16F648 ile PIC16F628 ",
+ "arasında fazla bir fark bulunmamaktadır. Eğer bir işlemcinin desteklenmesini",
+ "istiyorsanız ve bana bildirirseniz ilgilenirim.",
+ "",
+ "LDMicro ile ladder diyagramını çizebilir, devrenizi denemek için gerçek zamanlı ",
+ "simülasyon yapabilirsiniz. Programınızın çalıştığından eminseniz programdaki ",
+ "giriş ve çıkışlara mikrokontrolörün bacaklarını atarsınız. İşlemci bacakları ",
+ "belli olduktan sonra programınızı derleyebilirsiniz. Derleme sonucunda oluşan",
+ "dosya .hex dosyasıdır. Bu dosyayı PIC/AVR programlayıcı ile işlemcinize kaydedersiniz.",
+ "PIC/AVR ile uğraşanlar konuya yabancı değildir.",
+ "",
+ "",
+ "LDMicro ticari PLC programları gibi tasarlanmıştır. Bazı eksiklikler vardır. ",
+ "Kitapçığı dikkatlice okumanızı tavsiye ederim. Kullanım esnasında PLC ve ",
+ "PIC/AVR hakkında temel bilgilere sahip olduğunuz düşünülmüştür.",
+ "",
+ "DİĞER AMAÇLAR",
+ "==================",
+ "",
+ "ANSI C kodunu oluşturmak mümkündür. C derleyicisi olan herhangi bir",
+ "işlemci için bu özellikten faydalanabilirsiniz. Ancak çalıştırmak için ",
+ "gerekli dosyaları siz sağlamalısınız. Yani, LDMicro sadece PlcCycle()",
+ "isimli fonksiyonu üretir. Her döngüde PlcCycle fonksiyonunu çağırmak, ve",
+ "PlcCycle() fonksiyonunun çağırdığı dijital girişi yazma/okuma vs gibi",
+ "G/Ç fonksiyonları sizin yapmanız gereken işlemlerdir.",
+ "Oluşturulan kodu incelerseniz faydalı olur.",
+ "",
+ "KOMUT SATIRI SEÇENEKLERİ",
+ "========================",
+ "",
+ "Normal şartlarda ldmicro.exe komut satırından seçenek almadan çalışır.",
+ "LDMicro'ya komut satırından dosya ismi verebilirsiniz. Örneğin;komut",
+ "satırından 'ldmicro.exe asd.ld' yazarsanız bu dosya açılmaya çalışırlır.",
+ "Dosya varsa açılır. Yoksa hata mesajı alırsınız. İsterseniz .ld uzantısını",
+ "ldmicro.exe ile ilişkilendirirseniz .ld uzantılı bir dosyayı çift tıklattığınızda",
+ "bu dosya otomatik olarak açılır. Bkz. Klasör Seçenekleri (Windows).",
+ "",
+ "`ldmicro.exe /c src.ld dest.hex', şeklinde kullanılırsa src.ld derlenir",
+ "ve hazırlanan derleme dest.hex dosyasına kaydedilir. İşlem bitince LDMicro kapanır.",
+ "Oluşabilecek tüm mesajlar konsoldan görünür.",
+ "",
+ "TEMEL BİLGİLER",
+ "==============",
+ "",
+ "LDMicro açıldığında boş bir program ile başlar. Varolan bir dosya ile başlatırsanız",
+ "bu program açılır. LDMicro kendi dosya biçimini kullandığından diğer dosya",
+ "biçimlerinden dosyaları açamazsınız.",
+ "",
+ "Boş bir dosya ile başlarsanız ekranda bir tane boş satır görürsünüz. Bu satıra",
+ "komutları ekleyebilir, satır sayısını artırabilirsiniz. Satırlara Rung denilir.",
+ "Örneğin; Komutlar->Kontak Ekle diyerek bir kontak ekleyebilirsiniz. Bu kontağa",
+ "'Xnew' ismi verilir. 'X' bu kontağın işlemcinin bacağına denk geldiğini gösterir.",
+ "Bu kontağa derlemeden önce isim vermeli ve mikrokontrolörün bir bacağı ile",
+ "eşleştirmelisiniz. Eşleştirme işlemi içinde önce işlemciyi seçmelisiniz.",
+ "Elemanların ilk harfi o elemanın ne olduğu ile ilgilidir. Örnekler:",
+ "",
+ " * Xname -- mikrokontrolördeki bir giriş bacağı",
+ " * Yname -- mikrokontrolördeki bir çıkış bacağı",
+ " * Rname -- `dahili röle': hafızada bir bit.",
+ " * Tname -- zamanlayıcı; turn-on, turn-off yada retentive ",
+ " * Cname -- sayıcı, yukarı yada aşağı sayıcı",
+ " * Aname -- A/D çeviriciden okunan bir tamsayı değer",
+ " * name -- genel değişken (tamsayı)",
+ "",
+ "İstediğiniz ismi seçebilirsiniz. Seçilen bir isim nerede kullanılırsa",
+ "kullanılsın aynı yere denk gelir. Örnekler; bir satırda Xasd kullandığınızda",
+ "bir başka satırda Xasd kullanırsanız aynı değere sahiptirler. ",
+ "Bazen bu mecburi olarak kullanılmaktadır. Ancak bazı durumlarda hatalı olabilir.",
+ "Mesela bir (TON) Turn-On Gecikmeye Tgec ismini verdikten sonra bir (TOF)",
+ "Turn_Off gecikme devresine de Tgec ismini verirseniz hata yapmış olursunuz.",
+ "Dikkat ederseniz yaptığınız bir mantık hatasıdır. Her gecikme devresi kendi",
+ "hafızasına sahip olmalıdır. Ama Tgec (TON) turn-on gecikme devresini sıfırlamak",
+ "için kullanılan RES komutunda Tgec ismini kullanmak gerekmektedir.",
+ "",
+ "Değişken isimleri harfleri, sayıları, alt çizgileri ihtiva edebilir.",
+ "(_). Değişken isimleri sayı ile başlamamalıdır. Değişken isimleri büyük-küçük harf duyarlıdır.",
+ "Örneğin; TGec ve Tgec aynı zamanlayıcılar değildir.",
+ "",
+ "",
+ "Genel değişkenlerle ilgili komutlar (MOV, ADD, EQU vs) herhangi bir",
+ "isimdeki değişkenlerle çalışır. Bunun anlamı bu komutlar zamanlayıcılar",
+ "ve sayıcılarla çalışır. Zaman zaman bu faydalı olabilir. Örneğin; bir ",
+ "zamanlayıcının değeri ile ilgili bir karşılaştırma yapabilirsiniz.",
+ "",
+ "Değişkenler hr zaman için 16 bit tamsayıdır. -32768 ile 32767 arasında",
+ "bir değere sahip olabilirler. Her zaman için işaretlidir. (+ ve - değere",
+ "sahip olabilirler) Onluk sayı sisteminde sayı kullanabilirsiniz. Tırnak",
+ "arasına koyarak ('A', 'z' gibi) ASCII karakterler kullanabilirsiniz.",
+ "",
+ "Ekranın alt tarafındaki kısımda kullanılan tüm elemanların bir listesi görünür.",
+ "Bu liste program tarafından otomatik olarak oluşturulur ve kendiliğinden",
+ "güncelleştirilir. Sadece 'Xname', 'Yname', 'Aname' elemanları için",
+ "mikrokontrolörün bacak numaraları belirtilmelidir. Önce Ayarlar->İşlemci Seçimi",
+ "menüsünden işlemciyi seçiniz. Daha sonra G/Ç uçlarını çift tıklatarak açılan",
+ "pencereden seçiminizi yapınız.",
+ "",
+ "Komut ekleyerek veya çıkararak programınızı değiştirebilirsiniz. Programdaki",
+ "kursör eleman eklenecek yeri veya hakkında işlem yapılacak elemanı göstermek",
+ "amacıyla yanıp söner. Elemanlar arasında <Tab> tuşu ile gezinebilirsiniz. Yada",
+ "elemanı fare ile tıklatarak işlem yapılacak elemanı seçebilirsiniz. Kursör elemanın",
+ "solunda, sağında, altında ve üstünde olabilir. Solunda ve sağında olduğunda",
+ "ekleme yaptığınızda eklenen eleman o tarafa eklenir. Üstünde ve altında iken",
+ "eleman eklerseniz eklenen eleman seçili elemana paralel olarak eklenir.",
+ "Bazı işlemleri yapamazsınız. Örneğin bir bobinin sağına eleman ekleyemezsiniz.",
+ "LDMicro buna izin vermeyecektir.",
+ "",
+ "Program boş bir satırla başlar. Kendiniz alta ve üste satır ekleyerek dilediğiniz",
+ "gibi diyagramınızı oluşturabilirsiniz. Yukarıda bahsedildiği gibi alt devreler",
+ "oluşturabilirsiniz.",
+ "",
+ "Programınız yazdığınızda simülasyon yapabilir, .hex dosyasını oluşturabilirsiniz.",
+ "",
+ "SİMÜLASYON",
+ "==========",
+ "",
+ "Simülasyon moduna geçmek için Simülasyon->Simülasyon modu menüsünü tıklatabilir,",
+ "yada <Ctrl+M> tuş kombinasyonuna basabilirsiniz. Simülasyon modunda program",
+ "farklı bir görüntü alır. Kursör görünmez olur. Enerji alan yerler ve elemanlar",
+ "parlak kırmızı, enerji almayan yerler ve elemanlar gri görünür. Boşluk tuşuna",
+ "basarak bir çevrim ilerleyebilir yada menüden Simülasyon->Gerçek Zamanlı Simülasyonu Başlat",
+ "diyerek (veya <Ctrl+R>) devamlı bir çevrim başlatabilirsiniz. Ladder diyagramının",
+ "çalışmasına göre gerçek zamanlı olarak elemanlar ve yollar program tarafından değiştirilir.",
+ "",
+ "Giriş elemanlarının durumunu çift tıklatarak değiştirebilirsiniz. Mesela, 'Xname'",
+ "kontağını çift tıklatıranız açıktan kapalıya veya kapalıdan açığa geçiş yapar.",
+ "",
+ "DERLEME",
+ "=======",
+ "",
+ "Ladder diyagramının yapılmasındaki amaç işlemciye yüklenecek .hex dosyasının",
+ "oluşturulmasıdır. Buna 'derleme' denir. Derlemeden önce şu aşamalar tamamlanmalıdır:",
+ " 1- İşlemci seçilmelidir. Ayarlar->İşlemci Seçimi menüsünden yapılır.",
+ " 2- G/Ç uçlarının mikrokontrolördeki hangi bacaklara bağlanacağı seçilmelidir.",
+ " Elemanın üzerine çift tıklanır ve çıkan listeden seçim yapılır.",
+ " 3- Çevrim süresi tanımlanmalıdır. Ayarlar->İşlemci Ayarları menüsünden yapılır.",
+ " Bu süre işlemcinin çalıştığı frekansa bağlıdır. Çoğu uygulamalar için 10ms",
+ " uygun bir seçimdir. Aynı yerden kristal frekansını ayarlamayı unutmayınız.",
+ "",
+ "Artık kodu üretebilirsiniz. Derle->Derle yada Derle->Farklı Derle seçeneklerinden",
+ "birini kullanacaksınız. Aradaki fark Kaydet ve Farklı Kaydet ile aynıdır. Sonuçta",
+ "Intel IHEX dosyanız programınızda hata yoksa üretilecektir. Programınızda hata varsa",
+ "uyarı alırsınız.",
+ "",
+ "Progamlayıcınız ile bu dosyayı işlemcinize yüklemelisiniz. Buradaki en önemli nokta",
+ "işlemcinin konfigürasyon bitlerinin ayarlanmasıdır. PIC16 işlemciler için gerekli ",
+ "ayar bilgileri hex dosyasına kaydedildiğinden programlayıcınız bu ayarları algılayacaktır.",
+ "Ancak AVR işlemciler için gerekli ayarları siz yapmalısınız.",
+ "",
+ "KOMUTLAR ve ELEMANLAR",
+ "=====================",
+ "",
+ "> KONTAK, NORMALDE AÇIK Xname Rname Yname",
+ " ----] [---- ----] [---- ----] [----",
+ "",
+ " Normalde açık bir anahtar gibi davranır. Komutu kontrol eden sinyal 0 ise ",
+ " çıkışındaki sinyalde 0 olur. Eğer kontrol eden sinyal 1 olursa çıkışı da 1",
+ " olur ve çıkışa bağlı bobin aktif olur. Bu kontak işlemci bacağından alınan",
+ " bir giriş, çıkış bacağı yada dahili bir röle olabilir.",
+ "",
+ "",
+ "> KONTAK, NORMALDE KAPALI Xname Rname Yname",
+ " ----]/[---- ----]/[---- ----]/[----",
+ "",
+ " Normalde kapalı bir anahtar gibi davranır. Komutun kontrol eden sinyal 0 ise",
+ " çıkışı 1 olur. Eğer kontrol eden sinyal 1 olursa çıkışı 0 olur ve çıkışa",
+ " bağlı elemanlar pasif olur. Normalde çıkışa gerilim verilir, ancak bu kontağı ",
+ " kontrol eden sinyal 1 olursa kontağın çıkışında gerilim olmaz. Bu kontak ",
+ " işlemci bacağından alınan bir giriş, çıkış bacağı yada dahili bir röle olabilir",
+ "",
+ "",
+ "> BOBİN, NORMAL Rname Yname",
+ " ----( )---- ----( )----",
+ "",
+ " Elemana giren sinyal 0 ise dahili röle yada çıkış bacağı 0 yapılır.",
+ " Elemana giren sinyal 1 ise dahili röle yada çıkış bacağı 1 yapılır.",
+ " Bobine giriş değişkeni atamak mantıksızdır. Bu eleman bir satırda",
+ " sağdaki en son eleman olmalıdır.",
+ "",
+ "",
+ "> BOBİN, TERSLENMİŞ Rname Yname",
+ " ----(/)---- ----(/)----",
+ "",
+ " Elemana giren sinyal 0 ise dahili röle yada çıkış bacağı 1 yapılır.",
+ " Elemana giren sinyal 1 ise dahili röle yada çıkış bacağı 0 yapılır.",
+ " Bobine giriş değişkeni atamak mantıksızdır. Bu eleman bir satırda",
+ " sağdaki en son eleman olmalıdır. Normal bobinin tersi çalışır.",
+ " ",
+ "",
+ "> BOBİN, SET Rname Yname",
+ " ----(S)---- ----(S)----",
+ "",
+ " Elemana giren sinyal 1 ise dahili röle yada çıkış bacağı 1 yapılır.",
+ " Diğer durumlarda bu bobinin durumunda bir değişiklik olmaz. Bu komut",
+ " bobinin durumunu sadece 0'dan 1'e çevirir. Bu nedenle çoğunlukla",
+ " BOBİN-RESET ile beraber çalışır. Bu eleman bir satırda sağdaki en",
+ " son eleman olmalıdır.",
+ "",
+ "",
+ "> BOBİN, RESET Rname Yname",
+ " ----(R)---- ----(R)----",
+ "",
+ " Elemana giren sinyal 1 ise dahili röle yada çıkış bacağı 0 yapılır.",
+ " Diğer durumlarda bu bobinin durumunda bir değişiklik olmaz. Bu komut",
+ " bobinin durumunu sadece 1'dEn 0'a çevirir. Bu nedenle çoğunlukla",
+ " BOBİN-SET ile beraber çalışır. Bu eleman bir satırda sağdaki en",
+ " son eleman olmalıdır.",
+ "",
+ "",
+ "> TURN-ON GECİKME Tdon ",
+ " -[TON 1.000 s]-",
+ "",
+ " Bir zamanlayıcıdır. Girişindeki sinyal 0'dan 1'e geçerse ayarlanan",
+ " süre kadar sürede çıkış 0 olarak kalır, süre bitince çıkışı 1 olur. ",
+ " Girişindeki sinyal 1'den 0'a geçerse çıkış hemen 0 olur.",
+ " Girişi 0 olduğu zaman zamanlayıcı sıfırlanır. Ayrıca; ayarlanan süre",
+ " boyunca giriş 1 olarak kalmalıdır.",
+ "",
+ " Zamanlayıcı 0'dan başlayarak her çevrim süresinde 1 artarak sayar.",
+ " Sayı ayarlanan süreye eşit yada büyükse çıkış 1 olur. Zamanlayıcı",
+ " değişkeni üzerinde işlem yapmak mümkündür. (Örneğin MOV komutu ile)",
+ "",
+ "",
+ "> TURN-OFF GECİKME Tdoff ",
+ " -[TOF 1.000 s]-",
+ "",
+ " Bir zamanlayıcıdır. Girişindeki sinyal 1'den 0'a geçerse ayarlanan",
+ " süre kadar sürede çıkış 1 olarak kalır, süre bitince çıkışı 0 olur. ",
+ " Girişindeki sinyal 0'dan 1'e geçerse çıkış hemen 1 olur.",
+ " Girişi 0'dan 1'e geçtiğinde zamanlayıcı sıfırlanır. Ayrıca; ayarlanan",
+ " süre boyunca giriş 0 olarak kalmalıdır.",
+ "",
+ " Zamanlayıcı 0'dan başlayarak her çevrim süresinde 1 artarak sayar.",
+ " Sayı ayarlanan süreye eşit yada büyükse çıkış 1 olur. Zamanlayıcı",
+ " değişkeni üzerinde işlem yapmak mümkündür. (Örneğin MOV komutu ile)",
+ "",
+ "",
+ "> SÜRE SAYAN TURN-ON GECİKME Trto ",
+ " -[RTO 1.000 s]-",
+ "",
+ " Bu zamanlayıcı girişindeki sinyalin ne kadar süre ile 1 olduğunu",
+ " ölçer. Ayaralanan süre boyunca giriş 1 ise çıkışı 1 olur. Aksi halde",
+ " çıkışı 0 olur. Ayarlanan süre devamlı olması gerekmez. Örneğin; süre ",
+ " 1 saniyeye ayarlanmışsa ve giriş önce 0.6 sn 1 olmuşsa, sonra 2.0 sn",
+ " boyunca 0 olmuşsa daha sonra 0.4 sn boyunca giriş tekrar 1 olursa",
+ " 0.6 + 0.4 = 1sn olduğundan çıkış 1 olur. Çıkış 1 olduktan sonra",
+ " giriş 0 olsa dahi çıkış 0'a dönmez. Bu nedenle zamanlayıcı RES reset",
+ " komutu ile resetlenmelidir.",
+ "",
+ " Zamanlayıcı 0'dan başlayarak her çevrim süresinde 1 artarak sayar.",
+ " Sayı ayarlanan süreye eşit yada büyükse çıkış 1 olur. Zamanlayıcı",
+ " değişkeni üzerinde işlem yapmak mümkündür. (Örneğin MOV komutu ile)",
+ "",
+ "",
+ "> RESET (SAYICI SIFIRLAMASI) Trto Citems",
+ " ----{RES}---- ----{RES}----",
+ "",
+ " Bu komut bir zamanlayıcı veya sayıcıyı sıfırlar. TON ve TOF zamanlayıcı",
+ " komutları kendiliğinden sıfırlandığından bu komuta ihtiyaç duymazlar.",
+ " RTO zamanlayıcısı ve CTU/CTD sayıcıları kendiliğinden sıfırlanmadığından",
+ " sıfırlanmaları için kullanıcı tarafından bu komutile sıfırlanması",
+ " gerekir. Bu komutun girişi 1 olduğunda sayıcı/zamanlayıcı sıfırlanır.",
+ " Bu komut bir satırın sağındaki son komut olmalıdır.",
+ "",
+ "",
+ "> YÜKSELEN KENAR _",
+ " --[OSR_/ ]--",
+ "",
+ " Bu komutun çıkışı normalde 0'dır. Bu komutun çıkışının 1 olabilmesi",
+ " için bir önceki çevrimde girişinin 0 şimdiki çevrimde girişinin 1 ",
+ " olması gerekir. Komutun çıkışı bir çevrimlik bir pals üretir.",
+ " Bu komut bir sinyalin yükselen kenarında bir tetikleme gereken",
+ " uygulamalarda faydalıdır.",
+ " ",
+ "",
+ "> DÜŞEN KENAR _",
+ " --[OSF \\_]--",
+ "",
+ " Bu komutun çıkışı normalde 0'dır. Bu komutun çıkışının 1 olabilmesi",
+ " için bir önceki çevrimde girişinin 1 şimdiki çevrimde girişinin 0 ",
+ " olması gerekir. Komutun çıkışı bir çevrimlik bir pals üretir.",
+ " Bu komut bir sinyalin düşen kenarında bir tetikleme gereken",
+ " uygulamalarda faydalıdır.",
+ "",
+ "",
+ "> KISA DEVRE, AÇIK DEVRE",
+ " ----+----+---- ----+ +----",
+ "",
+ " Kısa devrenin çıkışı her zaman girişinin aynısıdır.",
+ " Açık devrenin çıkışı her zaman 0'dır. Bildiğimiz açık/kısa devrenin",
+ " aynısıdır. Genellikle hata aramada kullanılırlar.",
+ "",
+ "> ANA KONTROL RÖLESİ",
+ " -{MASTER RLY}-",
+ "",
+ " Normalde her satırın ilk girişi 1'dir. Birden fazla satırın tek bir şart ile ",
+ " kontrol edilmesi gerektiğinde paralel bağlantı yapmak gerekir. Bu ise zordur.",
+ " Bu işlemi kolayca yapabilmek için ana kontrol rölesini kullanabiliriz.",
+ " Ana kontrol rölesi eklendiğinde kendisinden sonraki satırlar bu röleye bağlı",
+ " hale gelir. Böylece; birden fazla satır tek bir şart ile kontrolü sağlanır.",
+ " Bir ana kontrol rölesi kendisinden sonra gelen ikinci bir ana kontrol",
+ " rölesine kadar devam eder. Diğer bir deyişle birinci ana kontrol rölesi",
+ " başlangıcı ikincisi ise bitişi temsil eder. Ana kontrol rölesi kullandıktan",
+ " sonra işlevini bitirmek için ikinci bir ana kontrol rölesi eklemelisiniz.",
+ "",
+ "> MOVE {destvar := } {Tret := }",
+ " -{ 123 MOV}- -{ srcvar MOV}-",
+ "",
+ " Girişi 1 olduğunda verilen sabit sayıyı (123 gibi) yada verilen değişkenin",
+ " içeriğini (srcvar) belirtilen değişkene (destvar) atar. Giriş 0 ise herhangi",
+ " bir işlem olmaz. Bu komut ile zamanlayıcı ve sayıcılar da dahil olmak üzere",
+ " tüm değişkenlere değer atayabilirsiniz. Örneğin Tsay zamanlayıcısına MOVE ile",
+ " 0 atamak ile RES ile sıfırlamak aynı sonucu doğurur. Bu komut bir satırın",
+ " sağındaki en son komut olmalıdır.",
+ "",
+ "> MATEMATİK İŞLEMLER {ADD kay :=} {SUB Ccnt :=}",
+ " -{ 'a' + 10 }- -{ Ccnt - 10 }-",
+ "",
+ "> {MUL dest :=} {DIV dv := }",
+ " -{ var * -990 }- -{ dv / -10000}-",
+ "",
+ " Bu komutun girişi doğru ise belirtilen hedef değişkenine verilen matematik",
+ " işlemin sonucunu kaydeder. İşlenen bilgi zamanlayıcı ve sayıcılar dahil",
+ " olmak üzere değişkenler yada sabit sayılar olabilir. İşlenen bilgi 16 bit",
+ " işaretli sayıdır. Her çevrimde işlemin yeniden yapıldığı unutulmamalıdır.",
+ " Örneğin artırma yada eksiltme yapıyorsanız yükselen yada düşen kenar",
+ " kullanmanız gerekebilir. Bölme (DIV) virgülden sonrasını keser. Örneğin;",
+ " 8 / 3 = 2 olur. Bu komut bir satırın sağındaki en son komut olmalıdır.",
+ "",
+ "",
+ "> KARŞILAŞTIRMA [var ==] [var >] [1 >=]",
+ " -[ var2 ]- -[ 1 ]- -[ Ton]-",
+ "",
+ "> [var /=] [-4 < ] [1 <=]",
+ " -[ var2 ]- -[ vartwo]- -[ Cup]-",
+ "",
+ " Değişik karşılaştırma komutları vardır. Bu komutların girişi doğru (1)",
+ " ve verilen şart da doğru ise çıkışları 1 olur.",
+ "",
+ "",
+ "> SAYICI Cname Cname",
+ " --[CTU >=5]-- --[CTD >=5]--",
+ "",
+ " Sayıcılar girişlerinin 0'dan 1'e her geçişinde yani yükselen kenarında",
+ " değerlerini 1 artırır (CTU) yada eksiltirler (CTD). Verilen şart doğru ise",
+ " çıkışları aktif (1) olur. CTU ve CTD sayıcılarına aynı ismi erebilirsiniz.",
+ " Böylece aynı sayıcıyı artırmış yada eksiltmiş olursunuz. RES komutu sayıcıları",
+ " sıfırlar. Sayıcılar ile genel değişkenlerle kullandığınız komutları kullanabilirsiniz.",
+ "",
+ "",
+ "> DAİRESEL SAYICI Cname",
+ " --{CTC 0:7}--",
+ "",
+ " Normal yukarı sayıcıdan farkı belirtilen limite ulaşınca sayıcı tekrar 0'dan başlar",
+ " Örneğin sayıcı 0, 1, 2, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 0, 2,.... şeklinde",
+ " sayabilir. Yani bir dizi sayıcı olarak düşünülebilir. CTC sayıcılar girişlerinin",
+ " yükselen kenarında değer değiştirirler. Bu komut bir satırın sağındaki",
+ " en son komut olmalıdır.",
+ " ",
+ "",
+ "> SHIFT REGISTER {SHIFT REG }",
+ " -{ reg0..3 }-",
+ "",
+ " Bir dizi değişken ile beraber çalışır. İsim olarak reg verdiğinizi ve aşama ",
+ " sayısını 3 olarak tanımladıysanız reg0, reg1, reg2 değikenleri ile çalışırsınız.",
+ " Kaydedicinin girişi reg0 olur. Girişin her yükselen kenarında değerler kaydedicide",
+ " bir sağa kayar. Mesela; `reg2 := reg1'. and `reg1 := reg0'. `reg0' değişmez.",
+ " Geniş bir kaydedici hafızada çok yer kaplar.",
+ " Bu komut bir satırın sağındaki en son komut olmalıdır.",
+ "",
+ "",
+ "> DEĞER TABLOSU {dest := }",
+ " -{ LUT[i] }-",
+ "",
+ " Değer tablosu sıralanmış n adet değer içeren bir tablodur. Girişi doğru olduğunda",
+ " `dest' tamsayı değişkeni `i' tamsayı değişkenine karşılık gelen değeri alır. Sıra",
+ " 0'dan başlar. bu nedenle `i' 0 ile (n-1) arasında olabilir. `i' bu değerler ",
+ " arasında değilse komutun ne yapacağı tanımlı değildir.",
+ " Bu komut bir satırın sağındaki en son komut olmalıdır.",
+ "",
+ "",
+ "> PIECEWISE LINEAR TABLE {yvar := }",
+ " -{ PWL[xvar] }-",
+ "",
+ " Bir matris tablo olarak düşünülebilir. Bir değere bağlı olarak değerin önceden",
+ " belirlenen bir başka değer ile değiştirilmesi içi oluşturulan bir tablodur.",
+ " Bu bir eğri oluşturmak, sensörden alınan değere göre çıkışta başka bir eğri",
+ " oluşturmak gibi amaçlar için kullanılabilir.",
+ "",
+ " Farzedelimki x tamsayı giriş değerini y tamsayı çıkış değerine yaklaştırmak ",
+ " istiyoruz. Değerlerin belirli noktalarda olduğunu biliyoruz. Örneğin;",
+ "",
+ " f(0) = 2",
+ " f(5) = 10",
+ " f(10) = 50",
+ " f(100) = 100",
+ "",
+ " Bu şu noktaların eğride olduğunu gösterir:",
+ "",
+ " (x0, y0) = ( 0, 2)",
+ " (x1, y1) = ( 5, 10)",
+ " (x2, y2) = ( 10, 50)",
+ " (x3, y3) = (100, 100)",
+ "",
+ " Dört değeri parçalı lineer tabloya gireriz. Komut, xvar'ın değerine bakarak",
+ " yvar'a değer verir. Örneğin, yukarıdaki örneğe bakarak, xvar = 10 ise",
+ " yvar = 50 olur.",
+ " ",
+ " Tabloya kayıtlı iki değerin arasında bir değer verirseniz verilen değer de",
+ " alınması gereken iki değerin arasında uygun gelen yerde bir değer olur.",
+ " Mesela; xvar=55 yazarsanız yvar=75 olur. (Tablodaki değerler (10,50) ve",
+ " (100,100) olduğuna göre). 55, 10 ve 100 değerlerinin ortasındadır. Bu",
+ " nedenle 55 ve 75 değerlerinin ortası olan 75 değeri alınır.",
+ " ",
+ " Değerler x koordinatında artan değerler olarak yazılmalıdır. 16 bit tamsayı",
+ " kullanan bazı değerler için arama tablosu üzerinde matematik işlemler",
+ " gerçekleşmeyebilir. Bu durumda LDMicro sizi uyaracaktır. Örneğin aşağıdaki",
+ " tablo bir hata oluşturacaktır:",
+ "",
+ " (x0, y0) = ( 0, 0)",
+ " (x1, y1) = (300, 300)",
+ "",
+ " Bu tip hataları noktalar arsında ara değerler oluşturarak giderebilirsiniz.",
+ " Örneğin aşağıdaki tablo yukarıdakinin aynısı olmasına rağmen hata ",
+ " oluşturmayacaktır.",
+ " ",
+ " (x0, y0) = ( 0, 0)",
+ " (x1, y1) = (150, 150)",
+ " (x2, y2) = (300, 300)",
+ "",
+ " Genelde 5 yada 6 noktadan daha fazla değer kullanmak gerekmeyecektir.",
+ " Daha fazla nokta demek daha fazla kod ve daha yavaş çalışma demektir.",
+ " En fazla 10 nokta oluşturabilirsiniz. xvar değişkenine x koordinatında",
+ " tablonun en yüksek değerinden daha büyük bir değer girmenin ve en düşük",
+ " değerinden daha küçük bir değer girmenin sonucu tanımlı değildir.",
+ " Bu komut bir satırın sağındaki en son komut olmalıdır.",
+ "",
+ "> A/D ÇEVİRİCİDEN OKUMA Aname",
+ " --{READ ADC}--",
+ "",
+ " LDmicro A/D çeviriciden değer okumak için gerekli kodları desteklediği",
+ " işlemciler için oluşturabilir. Komutun girişi 1 olduğunda A/D çeviriciden ",
+ " değer okunur ve okunan değer `Aname' değişkenine aktarılır. Bu değişken",
+ " üzerinde genel değişkenlerle kullanılabilen işlemler kullanılabilir.",
+ " (büyük, küçük, büyük yada eşit gibi). Bu değişkene işlemcinin bacaklarından",
+ " uygun biri tanımlanmalıdır. Komutun girişi 0 ise `Aname'değişkeninde bir",
+ " değişiklik olmaz.",
+ " ",
+ " Şu an desteklenen işlemciler için; 0 Volt için ADC'den okunan değer 0, ",
+ " Vdd (besleme gerilimi) değerine eşit gerilim değeri için ADC'den okunan değer",
+ " 1023 olmaktadır. AVR kullanıyorsanız AREF ucunu Vdd besleme gerilimine ",
+ " bağlayınız.",
+ " ",
+ " Aritmetik işlemler ADC değişkeni için kullanılabilir. Ayrıca bacak tanımlarken",
+ " ADC olmayan bacakların tanımlanmasını LDMicro engelleyecektir.",
+ " Bu komut bir satırın sağındaki en son komut olmalıdır.",
+ "",
+ " > PWM PALS GENİŞLİĞİ AYARI duty_cycle",
+ " -{PWM 32.8 kHz}-",
+ "",
+ " LDmicro desteklediği mikrokontrolörler için gerekli PWM kodlarını üretebilir.",
+ " Bu komutun girişi doğru (1) olduğunda PWM sinyalinin pals genişliği duty_cycle",
+ " değişkeninin değerine ayarlanır. Bu değer 0 ile 100 arasında değişir. Pals",
+ " genişliği yüzde olarak ayarlanır. Bir periyot 100 birim kabul edilirse bu",
+ " genişliğin yüzde kaçının palsi oluşturacağı ayarlanır. 0 periyodun tümü sıfır",
+ " 100 ise periyodun tamamı 1 olsun anlamına gelir. 10 değeri palsin %10'u 1 geri",
+ " kalan %90'ı sıfır olsun anlamına gelir.",
+ "",
+ " PWM frekansını ayarlayabilirsiniz. Verilen değer Hz olarak verilir.",
+ " Verdiğiniz frekans kesinlikle ayarlanabilir olmalıdır. LDMicro verdiğiniz değeri",
+ " olabilecek en yakın değerle değiştirir. Yüksek hızlarda doğruluk azalır.",
+ " ",
+ " Bu komut bir satırın sağındaki en son komut olmalıdır.",
+ " Periyodun süresinin ölçülebilmesi için işlemcinin zamanlayıcılarının bir tanesi",
+ " kullanılır. Bu nedenle PWM en az iki tane zamanlayıcısı olan işlemcilerde kullanılır.",
+ " PWM PIC16 işlemcilerde CCP2'yi, AVR'lerde ise OC2'yi kullanır.",
+ "",
+ "",
+ "> EEPROMDA SAKLA saved_var",
+ " --{PERSIST}--",
+ "",
+ " Bu komut ile belirtilen değişkenin EEPROM'da saklanması gereken bir değişken olduğunu",
+ " belirmiş olursunuz. Komutun girişi doğru ise belirtilen değişkenin içeriği EEPROM'a",
+ " kaydedilir. Enerji kesildiğinde kaybolmaması istenen değerler için bu komut kullanılır.",
+ " Değişkenin içeriği gerilim geldiğinde tekrar EEPROM'dan yüklenir. Ayrıca;",
+ " değişkenin içeriği her değiştiğinde yeni değer tekrar EEPROM'a kaydedilir.",
+ " Ayrıca bir işlem yapılması gerekmez.",
+ " Bu komut bir satırın sağındaki en son komut olmalıdır.",
+ "",
+ "************************",
+ "> UART (SERİ BİLGİ) AL var",
+ " --{UART RECV}--",
+ "",
+ " LDmicro belirli işlemciler için gerekli UART kodlarını üretebilir. AVR işlemcilerde",
+ " sadece UART1 (UART0) değil) desteklenmektedir. İletişim hızı (baudrate) ayarlarını ",
+ " Ayarlar->İşlemci Ayarları menüsünden yapmalısınız. Hız kristal frekansına bağlı olup,",
+ " bazı hızlar desteklenmeyebilir. Bu durumda LDMicro sizi uyaracaktır. ",
+ " ",
+ " Bu komutun girişi yanlışsa herhangi bir işlem yapılmaz. Doğru ise UART'dan 1 karakter",
+ " alınmaya çalışılır. Okuma yapılamaz ise komutun çıkışı yanlış (0) olur. Karakter",
+ " okunursa okunan karakter `var' değişkeninde saklanır ve komutun çıkışı doğru (1) olur.",
+ " Çıkışın doğru olması sadece bir PLC çevrimi sürer.",
+ "",
+ "",
+ "> UART (SERİ BİLGİ) GÖNDER var",
+ " --{UART SEND}--",
+ "",
+ " LDmicro belirli işlemciler için gerekli UART kodlarını üretebilir. AVR işlemcilerde",
+ " sadece UART1 (UART0) değil) desteklenmektedir. İletişim hızı (baudrate) ayarlarını ",
+ " Ayarlar->İşlemci Ayarları menüsünden yapmalısınız. Hız kristal frekansına bağlı olup,",
+ " bazı hızlar desteklenmeyebilir. Bu durumda LDMicro sizi uyaracaktır.",
+ " ",
+ " Bu komutun girişi yanlışsa herhangi bir işlem yapılmaz. Doğru ise UART'dan 1 karakter",
+ " gönderilir. Gönderilecek karakter gönderme işleminden önce `var' değişkeninde saklı",
+ " olmalıdır. Komutun çıkışı UART meşgulse (bir karakterin gönderildiği sürece)",
+ " doğru (1) olur. Aksi halde yanlış olur.",
+ " Çıkışın doğru olması sadece bir PLC çevrimi sürer.",
+ " ",
+ " Karakterin gönderilmesi belirli bir zaman alır. Bu nedenle başka bir karakter",
+ " göndermeden önce önceki karakterin gönderildiğini kontrol ediniz veya gönderme",
+ " işlemlerinin arasına geikme ekleyiniz. Komutun girişini sadece çıkış yanlış",
+ " (UART meşgul değilse)ise doğru yapınız.",
+ "",
+ " Bu komut yerine biçimlendirilmiş kelime komutunu (bir sonraki komut) inceleyiniz.",
+ " Biçimlendirilmiş kelime komutunun kullanımı daha kolaydır. İstediğiniz işlemleri",
+ " daha rahat gerçekleştirebilirsiniz.",
+ "",
+ "",
+ "> UART ÜZERİNDEN BİÇİMLENDİRİLMİŞ KELİME var",
+ " -{\"Pressure: \\3\\r\\n\"}-",
+ "",
+ " LDmicro belirli işlemciler için gerekli UART kodlarını üretebilir. AVR işlemcilerde",
+ " sadece UART1 (UART0) değil) desteklenmektedir. İletişim hızı (baudrate) ayarlarını ",
+ " Ayarlar->İşlemci Ayarları menüsünden yapmalısınız. Hız kristal frekansına bağlı olup,",
+ " bazı hızlar desteklenmeyebilir. Bu durumda LDMicro sizi uyaracaktır.",
+ "",
+ " Bu komutun girişi yanlıştan doğruya geçerse (yükselen kenar) ise seri port üzerinden",
+ " tüm kelimeyi gönderir. Eğer kelime `\\3' özel kodunu içeriyorsa dizi içeriği ",
+ " `var' değişkenin içeriği otomatik olarak kelimeye (string) çevrilerek`var'",
+ " değişkeninin içeriği ile değiştirilir. Değişkenin uzunluğu 3 karakter olacak şekilde",
+ " değiştirilir. Mesela; `var' değişkeninin içeriği 35 ise kelime 35 rakamının başına bir",
+ " adet boşul eklenerek `Pressure: 35\\r\\n' haline getirilir. Veya `var'değişkeninin",
+ " içeriği 1453 ise yapılacak işlem belli olmaz. Bu durumda `\\4' kullanmak gerekebilir.",
+ "",
+ " Değişken negatif bir sayı olabilecekse `\\-3d' (veya `\\-4d') gibi uygun bir değer",
+ " kullanmalısınız. Bu durumda LDMicro negatif sayıların önüne eksi işareti, pozitif sayıların",
+ " önüne ise bir boşluk karakteri yerleştirecektir.",
+ "",
+ " Aynı anda birkaç işlem tanımlanırsa, yada UART ile ilgili işlemler birbirine",
+ " karışık hale getirilirse programın davranışı belirli olmayacaktır. Bu nedenle",
+ " dikkatli olmalısınız.",
+ "",
+ " Kullanılabilecek özel karakterler (escape kodları) şunlardır:",
+ " * \\r -- satır başına geç",
+ " * \\n -- yeni satır",
+ " * \\f -- kağıdı ilerlet (formfeed)",
+ " * \\b -- bir karakter geri gel (backspace)",
+ " * \\xAB -- ASCII karakter kodu 0xAB (hex)",
+ "",
+ " Bu komutun çıkışı bilgi gönderiyorken doğru diğer durumlarda yanlış olur.",
+ " Bu komut program hafızasında çok yer kaplar.",
+ "",
+ "",
+ "MATEMATİKSEL İŞLEMLER İLE İLGİLİ BİLGİ",
+ "======================================",
+ "",
+ "Unutmayın ki, LDMicro 16-bit tamsayı matematik komutlarına sahiptir.",
+ "Bu işlemlerde kullanılan değerler ve hesaplamanın sonucu -32768 ile",
+ "32767 arasında bir tamsayı olabilir.",
+ "",
+ "Mesela y = (1/x)*1200 formülünü hesaplamaya çalışalım. x 1 ile 20",
+ "arasında bir sayıdır. Bu durumda y 1200 ile 60 arasında olur. Bu sayı",
+ "16-bit bir tamsayı sınırları içindedir. Ladder diyagramımızı yazalım.",
+ "Önce bölelim, sonra çarpma işlemini yapalım:",
+ "",
+ " || {DIV temp :=} ||",
+ " ||---------{ 1 / x }----------||",
+ " || ||",
+ " || {MUL y := } ||",
+ " ||----------{ temp * 1200}----------||",
+ " || ||",
+ "",
+ "Yada bölmeyi doğrudan yapalım:",
+ "",
+ " || {DIV y :=} ||",
+ " ||-----------{ 1200 / x }-----------||",
+ "",
+ "Matematiksel olarak iki işlem aynıd sonucu vermelidir. Ama birinci işlem",
+ "yanlış sonuç verecektir. (y=0 olur). Bu hata `temp' değişkeninin 1'den",
+ "küçük sonuç vermesindendir.Mesela x = 3 iken (1 / x) = 0.333 olur. Ama",
+ "0.333 bir tamsayı değildir. Bu nedenle sonuç 0 olur. İkinci adımda ise",
+ "y = temp * 1200 = 0 olur. İkinci şekilde ise bölen bir tamsayı olduğundan",
+ "sonuç doğru çıkacaktır.",
+ "",
+ "İşlemlerinizde bir sorun varsa dikkatle kontrol ediniz. Ayrıca sonucun",
+ "başa dönmemesine de dikkat ediniz. Mesela 32767 + 1 = -32768 olur.",
+ "32767 sınırı aşılmış olacaktır. ",
+ "",
+ "Hesaplamalarınızda mantıksal değişimler yaparak doğru sonuçlar elde edebilirsiniz.",
+ "Örneğin; y = 1.8*x ise formülünüzü y = (9/5)*x şeklinde yazınız.(1.8 = 9/5)",
+ "y = (9*x)/5 şeklindeki bir kod sonucu daha tutarlı hale getirecektir.",
+ "performing the multiplication first:",
+ "",
+ " || {MUL temp :=} ||",
+ " ||---------{ x * 9 }----------||",
+ " || ||",
+ " || {DIV y :=} ||",
+ " ||-----------{ temp / 5 }-----------||",
+ "",
+ "",
+ "KODALAMA ŞEKLİ",
+ "==============",
+ "",
+ "Programın sağladığı kolaylıklardan faydalanın. Mesela:",
+ "",
+ " || Xa Ya ||",
+ " 1 ||-------] [--------------( )-------||",
+ " || ||",
+ " || Xb Yb ||",
+ " ||-------] [------+-------( )-------||",
+ " || | ||",
+ " || | Yc ||",
+ " || +-------( )-------||",
+ " || ||",
+ "",
+ "yazmak aşağıdakinden daha kolay olacaktır.",
+ "",
+ " || Xa Ya ||",
+ " 1 ||-------] [--------------( )-------||",
+ " || ||",
+ " || ||",
+ " || ||",
+ " || ||",
+ " || Xb Yb ||",
+ " 2 ||-------] [--------------( )-------||",
+ " || ||",
+ " || ||",
+ " || ||",
+ " || ||",
+ " || Xb Yc ||",
+ " 3 ||-------] [--------------( )-------||",
+ " || ||",
+ "",
+ " * * *",
+ "",
+ "Yazdığınız kodların sonuçlarına dikkat ediniz. Aşağıdaki satırlarda",
+ "mantıksız bir programlama yapılmıştır. Çünkü hem Xa hemde Xb aynı",
+ "anda doğru olabilir.",
+ "",
+ " || Xa {v := } ||",
+ " 1 ||-------] [--------{ 12 MOV}--||",
+ " || ||",
+ " || Xb {v := } ||",
+ " ||-------] [--------{ 23 MOV}--||",
+ " || ||",
+ " || ||",
+ " || ||",
+ " || ||",
+ " || [v >] Yc ||",
+ " 2 ||------[ 15]-------------( )-------||",
+ " || ||",
+ "",
+ "Aşağıdaki satırlar yukarda bahsi geçen tarzdadır. Ancak yapılan",
+ "işlem 4-bit binary sayı tamsayıya çevrilmektedir.",
+ "",
+ " || {v := } ||",
+ " 3 ||-----------------------------------{ 0 MOV}--||",
+ " || ||",
+ " || Xb0 {ADD v :=} ||",
+ " ||-------] [------------------{ v + 1 }-----------||",
+ " || ||",
+ " || Xb1 {ADD v :=} ||",
+ " ||-------] [------------------{ v + 2 }-----------||",
+ " || ||",
+ " || Xb2 {ADD v :=} ||",
+ " ||-------] [------------------{ v + 4 }-----------||",
+ " || ||",
+ " || Xb3 {ADD v :=} ||",
+ " ||-------] [------------------{ v + 8 }-----------||",
+ " || ||",
+ "",
+ "",
+ "HATALAR (BUG)",
+ "=============",
+ "",
+ "LDmicro tarafından üretilen kodlar çok verimli kodlar değildir. Yavaş çalışan",
+ "ve hafızada fazla yer kaplayan kodlar olabilirler. Buna rağmen orta büyüklükte",
+ "bir PIC veya AVR küçük bir PLC'nin yaptığı işi yapar. Bu nedenle diğer sorunlar",
+ "yer yer gözardı edlebilir.",
+ "",
+ "Değişken isimleri çok uzun olmamalıdır. ",
+ "",
+ "Programınız yada kullandığınız hafıza seçtiğiniz işlemcinin sahip olduğundan",
+ "büyükse LDMicro hata vermeyebilir. Dikkat etmezseniz programınız hatalı çalışacaktır.",
+ "",
+ "Bulduğunuz hataları yazara bildiriniz.",
+ "",
+ "Teşekkürler:",
+ " * Marcelo Solano, Windows 98'deki UI problemini bildirdiği için,",
+ " * Serge V. Polubarjev, PIC16F628 işlemcisi seçildiğinde RA3:0'ın çalışmadığı",
+ " ve nasıl düzelteceğimi bildirdiği için,",
+ " * Maxim Ibragimov, ATmega16 ve ATmega162 işlemcileri test ettikleri, problemleri",
+ " buldukları ve bildirdikleri için,",
+ " * Bill Kishonti, sıfıra bölüm hatası olduğunda simülasyonun çöktüğünü bildirdikleri",
+ " için,",
+ " * Mohamed Tayae, PIC16F628 işlemcisinde EEPROM'da saklanması gereken değişkenlerin",
+ " aslında saklanmadığını bildirdiği için,",
+ " * David Rothwell, kullanıcı arayüzündeki birkaç problemi ve \"Metin Dosyası Olarak Kaydet\"",
+ " fonksiyonundaki problemi bildirdiği için.",
+ "",
+ "",
+ "KOPYALAMA VE KULLANIM ŞARTLARI",
+ "==============================",
+ "",
+ "LDMICRO TARAFINDAN ÜRETİLEN KODU İNSAN HAYATI VE İNSAN HAYATINI ETKİLEYEBİLECEK",
+ "PROJELERDE KULLANMAYINIZ. LDMICRO PROGRAMCISI LDMICRO'NUN KENDİNDEN VE LDMICRO",
+ "İLE ÜRETİLEN KODDAN KAYNAKLANAN HİÇBİR PROBLEM İÇİN SORUMLULUK KABUL ETMEMEKTEDİR.",
+ "",
+ "Bu program ücretsiz bir program olup, dilediğiniz gibi dağıtabilirsiniz,",
+ "kaynak kodda değişiklik yapabilirsiniz. Programın kullanımı Free Software Foundation",
+ "tarafından yazılan GNU General Public License (version 3 ve sonrası)şartlarına bağlıdır.",
+ "",
+ "Program faydalı olması ümidiyle dağıtılmıştır. Ancak hiçbir garanti verilmemektedir.",
+ "Detaylar için GNU General Public License içeriğine bakınız.",
+ "",
+ "Söz konusu sözleşmenin bir kopyası bu programla beraber gelmiş olması gerekmektedir.",
+ "Gelmediyse <http://www.gnu.org/licenses/> adresinde bulabilirsiniz.",
+ "",
+ "",
+ "Jonathan Westhues",
+ "",
+ "Rijswijk -- Dec 2004",
+ "Waterloo ON -- Jun, Jul 2005",
+ "Cambridge MA -- Sep, Dec 2005",
+ " Feb, Mar 2006",
+ " Feb 2007",
+ "",
+ "Email: user jwesthues, at host cq.cx",
+ "",
+ "Türkçe Versiyon : <http://tekelektirik.com/public/ldmicro.rar>",
+ NULL
+};
+#endif
+
+#if defined(LDLANG_EN) || defined(LDLANG_ES) || defined(LDLANG_IT) || defined(LDLANG_PT)
+char *HelpText[] = {
+ "",
+ "INTRODUCTION",
+ "============",
+ "",
+ "LDmicro generates native code for certain Microchip PIC16 and Atmel AVR",
+ "microcontrollers. Usually software for these microcontrollers is written",
+ "in a programming language like assembler, C, or BASIC. A program in one",
+ "of these languages comprises a list of statements. These languages are",
+ "powerful and well-suited to the architecture of the processor, which",
+ "internally executes a list of instructions.",
+ "",
+ "PLCs, on the other hand, are often programmed in `ladder logic.' A simple",
+ "program might look like this:",
+ "",
+ " || ||",
+ " || Xbutton1 Tdon Rchatter Yred ||",
+ " 1 ||-------]/[---------[TON 1.000 s]-+-------]/[--------------( )-------||",
+ " || | ||",
+ " || Xbutton2 Tdof | ||",
+ " ||-------]/[---------[TOF 2.000 s]-+ ||",
+ " || ||",
+ " || ||",
+ " || ||",
+ " || Rchatter Ton Tnew Rchatter ||",
+ " 2 ||-------]/[---------[TON 1.000 s]----[TOF 1.000 s]---------( )-------||",
+ " || ||",
+ " || ||",
+ " || ||",
+ " ||------[END]---------------------------------------------------------||",
+ " || ||",
+ " || ||",
+ "",
+ "(TON is a turn-on delay; TOF is a turn-off delay. The --] [-- statements",
+ "are inputs, which behave sort of like the contacts on a relay. The",
+ "--( )-- statements are outputs, which behave sort of like the coil of a",
+ "relay. Many good references for ladder logic are available on the Internet",
+ "and elsewhere; details specific to this implementation are given below.)",
+ "",
+ "A number of differences are apparent:",
+ "",
+ " * The program is presented in graphical format, not as a textual list",
+ " of statements. Many people will initially find this easier to",
+ " understand.",
+ "",
+ " * At the most basic level, programs look like circuit diagrams, with",
+ " relay contacts (inputs) and coils (outputs). This is intuitive to",
+ " programmers with knowledge of electric circuit theory.",
+ "",
+ " * The ladder logic compiler takes care of what gets calculated",
+ " where. You do not have to write code to determine when the outputs",
+ " have to get recalculated based on a change in the inputs or a",
+ " timer event, and you do not have to specify the order in which",
+ " these calculations must take place; the PLC tools do that for you.",
+ "",
+ "LDmicro compiles ladder logic to PIC16 or AVR code. The following",
+ "processors are supported:",
+ " * PIC16F877",
+ " * PIC16F628",
+ " * PIC16F876 (untested)",
+ " * PIC16F88 (untested)",
+ " * PIC16F819 (untested)",
+ " * PIC16F887 (untested)",
+ " * PIC16F886 (untested)",
+ " * ATmega128",
+ " * ATmega64",
+ " * ATmega162 (untested)",
+ " * ATmega32 (untested)",
+ " * ATmega16 (untested)",
+ " * ATmega8 (untested)",
+ "",
+ "It would be easy to support more AVR or PIC16 chips, but I do not have",
+ "any way to test them. If you need one in particular then contact me and",
+ "I will see what I can do.",
+ "",
+ "Using LDmicro, you can draw a ladder diagram for your program. You can",
+ "simulate the logic in real time on your PC. Then when you are convinced",
+ "that it is correct you can assign pins on the microcontroller to the",
+ "program inputs and outputs. Once you have assigned the pins, you can",
+ "compile PIC or AVR code for your program. The compiler output is a .hex",
+ "file that you can program into your microcontroller using any PIC/AVR",
+ "programmer.",
+ "",
+ "LDmicro is designed to be somewhat similar to most commercial PLC",
+ "programming systems. There are some exceptions, and a lot of things",
+ "aren't standard in industry anyways. Carefully read the description",
+ "of each instruction, even if it looks familiar. This document assumes",
+ "basic knowledge of ladder logic and of the structure of PLC software",
+ "(the execution cycle: read inputs, compute, write outputs).",
+ "",
+ "",
+ "ADDITIONAL TARGETS",
+ "==================",
+ "",
+ "It is also possible to generate ANSI C code. You could use this with any",
+ "processor for which you have a C compiler, but you are responsible for",
+ "supplying the runtime. That means that LDmicro just generates source",
+ "for a function PlcCycle(). You are responsible for calling PlcCycle",
+ "every cycle time, and you are responsible for implementing all the I/O",
+ "(read/write digital input, etc.) functions that the PlcCycle() calls. See",
+ "the comments in the generated source for more details.",
+ "",
+ "Finally, LDmicro can generate processor-independent bytecode for a",
+ "virtual machine designed to run ladder logic code. I have provided a",
+ "sample implementation of the interpreter/VM, written in fairly portable",
+ "C. This target will work for just about any platform, as long as you",
+ "can supply your own VM. This might be useful for applications where you",
+ "wish to use ladder logic as a `scripting language' to customize a larger",
+ "program. See the comments in the sample interpreter for details.",
+ "",
+ "",
+ "COMMAND LINE OPTIONS",
+ "====================",
+ "",
+ "ldmicro.exe is typically run with no command line options. That means",
+ "that you can just make a shortcut to the program, or save it to your",
+ "desktop and double-click the icon when you want to run it, and then you",
+ "can do everything from within the GUI.",
+ "",
+ "If LDmicro is passed a single filename on the command line",
+ "(e.g. `ldmicro.exe asd.ld'), then LDmicro will try to open `asd.ld',",
+ "if it exists. An error is produced if `asd.ld' does not exist. This",
+ "means that you can associate ldmicro.exe with .ld files, so that it runs",
+ "automatically when you double-click a .ld file.",
+ "",
+ "If LDmicro is passed command line arguments in the form",
+ "`ldmicro.exe /c src.ld dest.hex', then it tries to compile `src.ld',",
+ "and save the output as `dest.hex'. LDmicro exits after compiling,",
+ "whether the compile was successful or not. Any messages are printed",
+ "to the console. This mode is useful only when running LDmicro from the",
+ "command line.",
+ "",
+ "",
+ "BASICS",
+ "======",
+ "",
+ "If you run LDmicro with no arguments then it starts with an empty",
+ "program. If you run LDmicro with the name of a ladder program (xxx.ld)",
+ "on the command line then it will try to load that program at startup.",
+ "LDmicro uses its own internal format for the program; it cannot import",
+ "logic from any other tool.",
+ "",
+ "If you did not load an existing program then you will be given a program",
+ "with one empty rung. You could add an instruction to it; for example",
+ "you could add a set of contacts (Instruction -> Insert Contacts) named",
+ "`Xnew'. `X' means that the contacts will be tied to an input pin on the",
+ "microcontroller. You could assign a pin to it later, after choosing a",
+ "microcontroller and renaming the contacts. The first letter of a name",
+ "indicates what kind of object it is. For example:",
+ "",
+ " * Xname -- tied to an input pin on the microcontroller",
+ " * Yname -- tied to an output pin on the microcontroller",
+ " * Rname -- `internal relay': a bit in memory",
+ " * Tname -- a timer; turn-on delay, turn-off delay, or retentive",
+ " * Cname -- a counter, either count-up or count-down",
+ " * Aname -- an integer read from an A/D converter",
+ " * name -- a general-purpose (integer) variable",
+ "",
+ "Choose the rest of the name so that it describes what the object does,",
+ "and so that it is unique within the program. The same name always refers",
+ "to the same object within the program. For example, it would be an error",
+ "to have a turn-on delay (TON) called `Tdelay' and a turn-off delay (TOF)",
+ "called `Tdelay' in the same program, since each counter needs its own",
+ "memory. On the other hand, it would be correct to have a retentive timer",
+ "(RTO) called `Tdelay' and a reset instruction (RES) associated with",
+ "`Tdelay', since it that case you want both instructions to work with",
+ "the same timer.",
+ "",
+ "Variable names can consist of letters, numbers, and underscores",
+ "(_). A variable name must not start with a number. Variable names are",
+ "case-sensitive.",
+ "",
+ "The general variable instructions (MOV, ADD, EQU, etc.) can work on",
+ "variables with any name. This means that they can access timer and",
+ "counter accumulators. This may sometimes be useful; for example, you",
+ "could check if the count of a timer is in a particular range.",
+ "",
+ "Variables are always 16 bit integers. This means that they can go",
+ "from -32768 to 32767. Variables are always treated as signed. You can",
+ "specify literals as normal decimal numbers (0, 1234, -56). You can also",
+ "specify ASCII character values ('A', 'z') by putting the character in",
+ "single-quotes. You can use an ASCII character code in most places that",
+ "you could use a decimal number.",
+ "",
+ "At the bottom of the screen you will see a list of all the objects in",
+ "the program. This list is automatically generated from the program;",
+ "there is no need to keep it up to date by hand. Most objects do not",
+ "need any configuration. `Xname', `Yname', and `Aname' objects must be",
+ "assigned to a pin on the microcontroller, however. First choose which",
+ "microcontroller you are using (Settings -> Microcontroller). Then assign",
+ "your I/O pins by double-clicking them on the list.",
+ "",
+ "You can modify the program by inserting or deleting instructions. The",
+ "cursor in the program display blinks to indicate the currently selected",
+ "instruction and the current insertion point. If it is not blinking then",
+ "press <Tab> or click on an instruction. Now you can delete the current",
+ "instruction, or you can insert a new instruction to the right or left",
+ "(in series with) or above or below (in parallel with) the selected",
+ "instruction. Some operations are not allowed. For example, no instructions",
+ "are allowed to the right of a coil.",
+ "",
+ "The program starts with just one rung. You can add more rungs by selecting",
+ "Insert Rung Before/After in the Logic menu. You could get the same effect",
+ "by placing many complicated subcircuits in parallel within one rung,",
+ "but it is more clear to use multiple rungs.",
+ "",
+ "Once you have written a program, you can test it in simulation, and then",
+ "you can compile it to a HEX file for the target microcontroller.",
+ "",
+ "",
+ "SIMULATION",
+ "==========",
+ "",
+ "To enter simulation mode, choose Simulate -> Simulation Mode or press",
+ "<Ctrl+M>. The program is shown differently in simulation mode. There is",
+ "no longer a cursor. The instructions that are energized show up bright",
+ "red; the instructions that are not appear greyed. Press the space bar to",
+ "run the PLC one cycle. To cycle continuously in real time, choose",
+ "Simulate -> Start Real-Time Simulation, or press <Ctrl+R>. The display of",
+ "the program will be updated in real time as the program state changes.",
+ "",
+ "You can set the state of the inputs to the program by double-clicking",
+ "them in the list at the bottom of the screen, or by double-clicking an",
+ "`Xname' contacts instruction in the program. If you change the state of",
+ "an input pin then that change will not be reflected in how the program",
+ "is displayed until the PLC cycles; this will happen automatically if",
+ "you are running a real time simulation, or when you press the space bar.",
+ "",
+ "",
+ "COMPILING TO NATIVE CODE",
+ "========================",
+ "",
+ "Ultimately the point is to generate a .hex file that you can program",
+ "into your microcontroller. First you must select the part number of the",
+ "microcontroller, under the Settings -> Microcontroller menu. Then you",
+ "must assign an I/O pin to each `Xname' or `Yname' object. Do this by",
+ "double-clicking the object name in the list at the bottom of the screen.",
+ "A dialog will pop up where you can choose an unallocated pin from a list.",
+ "",
+ "Then you must choose the cycle time that you will run with, and you must",
+ "tell the compiler what clock speed the micro will be running at. These",
+ "are set under the Settings -> MCU Parameters... menu. In general you",
+ "should not need to change the cycle time; 10 ms is a good value for most",
+ "applications. Type in the frequency of the crystal that you will use",
+ "with the microcontroller (or the ceramic resonator, etc.) and click okay.",
+ "",
+ "Now you can generate code from your program. Choose Compile -> Compile,",
+ "or Compile -> Compile As... if you have previously compiled this program",
+ "and you want to specify a different output file name. If there are no",
+ "errors then LDmicro will generate an Intel IHEX file ready for",
+ "programming into your chip.",
+ "",
+ "Use whatever programming software and hardware you have to load the hex",
+ "file into the microcontroller. Remember to set the configuration bits",
+ "(fuses)! For PIC16 processors, the configuration bits are included in the",
+ "hex file, and most programming software will look there automatically.",
+ "For AVR processors you must set the configuration bits by hand.",
+ "",
+ "",
+ "INSTRUCTIONS REFERENCE",
+ "======================",
+ "",
+ "> CONTACT, NORMALLY OPEN Xname Rname Yname",
+ " ----] [---- ----] [---- ----] [----",
+ "",
+ " If the signal going into the instruction is false, then the output",
+ " signal is false. If the signal going into the instruction is true,",
+ " then the output signal is true if and only if the given input pin,",
+ " output pin, or internal relay is true, else it is false. This",
+ " instruction can examine the state of an input pin, an output pin,",
+ " or an internal relay.",
+ "",
+ "",
+ "> CONTACT, NORMALLY CLOSED Xname Rname Yname",
+ " ----]/[---- ----]/[---- ----]/[----",
+ "",
+ " If the signal going into the instruction is false, then the output",
+ " signal is false. If the signal going into the instruction is true,",
+ " then the output signal is true if and only if the given input pin,",
+ " output pin, or internal relay is false, else it is false. This",
+ " instruction can examine the state of an input pin, an output pin,",
+ " or an internal relay. This is the opposite of a normally open contact.",
+ "",
+ "",
+ "> COIL, NORMAL Rname Yname",
+ " ----( )---- ----( )----",
+ "",
+ " If the signal going into the instruction is false, then the given",
+ " internal relay or output pin is cleared false. If the signal going",
+ " into this instruction is true, then the given internal relay or output",
+ " pin is set true. It is not meaningful to assign an input variable to a",
+ " coil. This instruction must be the rightmost instruction in its rung.",
+ "",
+ "",
+ "> COIL, NEGATED Rname Yname",
+ " ----(/)---- ----(/)----",
+ "",
+ " If the signal going into the instruction is true, then the given",
+ " internal relay or output pin is cleared false. If the signal going",
+ " into this instruction is false, then the given internal relay or",
+ " output pin is set true. It is not meaningful to assign an input",
+ " variable to a coil. This is the opposite of a normal coil. This",
+ " instruction must be the rightmost instruction in its rung.",
+ "",
+ "",
+ "> COIL, SET-ONLY Rname Yname",
+ " ----(S)---- ----(S)----",
+ "",
+ " If the signal going into the instruction is true, then the given",
+ " internal relay or output pin is set true. Otherwise the internal",
+ " relay or output pin state is not changed. This instruction can only",
+ " change the state of a coil from false to true, so it is typically",
+ " used in combination with a reset-only coil. This instruction must",
+ " be the rightmost instruction in its rung.",
+ "",
+ "",
+ "> COIL, RESET-ONLY Rname Yname",
+ " ----(R)---- ----(R)----",
+ "",
+ " If the signal going into the instruction is true, then the given",
+ " internal relay or output pin is cleared false. Otherwise the",
+ " internal relay or output pin state is not changed. This instruction",
+ " instruction can only change the state of a coil from true to false,",
+ " so it is typically used in combination with a set-only coil. This",
+ " instruction must be the rightmost instruction in its rung.",
+ "",
+ "",
+ "> TURN-ON DELAY Tdon ",
+ " -[TON 1.000 s]-",
+ "",
+ " When the signal going into the instruction goes from false to true,",
+ " the output signal stays false for 1.000 s before going true. When the",
+ " signal going into the instruction goes from true to false, the output",
+ " signal goes false immediately. The timer is reset every time the input",
+ " goes false; the input must stay true for 1000 consecutive milliseconds",
+ " before the output will go true. The delay is configurable.",
+ "",
+ " The `Tname' variable counts up from zero in units of scan times. The",
+ " TON instruction outputs true when the counter variable is greater",
+ " than or equal to the given delay. It is possible to manipulate the",
+ " counter variable elsewhere, for example with a MOV instruction.",
+ "",
+ "",
+ "> TURN-OFF DELAY Tdoff ",
+ " -[TOF 1.000 s]-",
+ "",
+ " When the signal going into the instruction goes from true to false,",
+ " the output signal stays true for 1.000 s before going false. When",
+ " the signal going into the instruction goes from false to true,",
+ " the output signal goes true immediately. The timer is reset every",
+ " time the input goes false; the input must stay false for 1000",
+ " consecutive milliseconds before the output will go false. The delay",
+ " is configurable.",
+ "",
+ " The `Tname' variable counts up from zero in units of scan times. The",
+ " TON instruction outputs true when the counter variable is greater",
+ " than or equal to the given delay. It is possible to manipulate the",
+ " counter variable elsewhere, for example with a MOV instruction.",
+ "",
+ "",
+ "> RETENTIVE TIMER Trto ",
+ " -[RTO 1.000 s]-",
+ "",
+ " This instruction keeps track of how long its input has been true. If",
+ " its input has been true for at least 1.000 s, then the output is",
+ " true. Otherwise the output is false. The input need not have been",
+ " true for 1000 consecutive milliseconds; if the input goes true",
+ " for 0.6 s, then false for 2.0 s, and then true for 0.4 s, then the",
+ " output will go true. After the output goes true it will stay true",
+ " even after the input goes false, as long as the input has been true",
+ " for longer than 1.000 s. This timer must therefore be reset manually,",
+ " using the reset instruction.",
+ "",
+ " The `Tname' variable counts up from zero in units of scan times. The",
+ " TON instruction outputs true when the counter variable is greater",
+ " than or equal to the given delay. It is possible to manipulate the",
+ " counter variable elsewhere, for example with a MOV instruction.",
+ "",
+ "",
+ "> RESET Trto Citems",
+ " ----{RES}---- ----{RES}----",
+ "",
+ " This instruction resets a timer or a counter. TON and TOF timers are",
+ " automatically reset when their input goes false or true, so RES is",
+ " not required for these timers. RTO timers and CTU/CTD counters are",
+ " not reset automatically, so they must be reset by hand using a RES",
+ " instruction. When the input is true, the counter or timer is reset;",
+ " when the input is false, no action is taken. This instruction must",
+ " be the rightmost instruction in its rung.",
+ "",
+ "",
+ "> ONE-SHOT RISING _",
+ " --[OSR_/ ]--",
+ "",
+ " This instruction normally outputs false. If the instruction's input",
+ " is true during this scan and it was false during the previous scan",
+ " then the output is true. It therefore generates a pulse one scan",
+ " wide on each rising edge of its input signal. This instruction is",
+ " useful if you want to trigger events off the rising edge of a signal.",
+ "",
+ "",
+ "> ONE-SHOT FALLING _",
+ " --[OSF \\_]--",
+ "",
+ " This instruction normally outputs false. If the instruction's input",
+ " is false during this scan and it was true during the previous scan",
+ " then the output is true. It therefore generates a pulse one scan",
+ " wide on each falling edge of its input signal. This instruction is",
+ " useful if you want to trigger events off the falling edge of a signal.",
+ "",
+ "",
+ "> SHORT CIRCUIT, OPEN CIRCUIT",
+ " ----+----+---- ----+ +----",
+ "",
+ " The output condition of a short-circuit is always equal to its",
+ " input condition. The output condition of an open-circuit is always",
+ " false. These are mostly useful for debugging.",
+ "",
+ "",
+ "> MASTER CONTROL RELAY",
+ " -{MASTER RLY}-",
+ "",
+ " By default, the rung-in condition of every rung is true. If a master",
+ " control relay instruction is executed with a rung-in condition of",
+ " false, then the rung-in condition for all following rungs becomes",
+ " false. This will continue until the next master control relay",
+ " instruction is reached (regardless of the rung-in condition of that",
+ " instruction). These instructions must therefore be used in pairs:",
+ " one to (maybe conditionally) start the possibly-disabled section,",
+ " and one to end it.",
+ "",
+ "",
+ "> MOVE {destvar := } {Tret := }",
+ " -{ 123 MOV}- -{ srcvar MOV}-",
+ "",
+ " When the input to this instruction is true, it sets the given",
+ " destination variable equal to the given source variable or",
+ " constant. When the input to this instruction is false nothing",
+ " happens. You can assign to any variable with the move instruction;",
+ " this includes timer and counter state variables, which can be",
+ " distinguished by the leading `T' or `C'. For example, an instruction",
+ " moving 0 into `Tretentive' is equivalent to a reset (RES) instruction",
+ " for that timer. This instruction must be the rightmost instruction",
+ " in its rung.",
+ "",
+ "",
+ "> ARITHMETIC OPERATION {ADD kay :=} {SUB Ccnt :=}",
+ " -{ 'a' + 10 }- -{ Ccnt - 10 }-",
+ "",
+ "> {MUL dest :=} {DIV dv := }",
+ " -{ var * -990 }- -{ dv / -10000}-",
+ "",
+ " When the input to this instruction is true, it sets the given",
+ " destination variable equal to the given expression. The operands",
+ " can be either variables (including timer and counter variables)",
+ " or constants. These instructions use 16 bit signed math. Remember",
+ " that the result is evaluated every cycle when the input condition",
+ " true. If you are incrementing or decrementing a variable (i.e. if",
+ " the destination variable is also one of the operands) then you",
+ " probably don't want that; typically you would use a one-shot so that",
+ " it is evaluated only on the rising or falling edge of the input",
+ " condition. Divide truncates; 8 / 3 = 2. This instruction must be",
+ " the rightmost instruction in its rung.",
+ "",
+ "",
+ "> COMPARE [var ==] [var >] [1 >=]",
+ " -[ var2 ]- -[ 1 ]- -[ Ton]-",
+ "",
+ "> [var /=] [-4 < ] [1 <=]",
+ " -[ var2 ]- -[ vartwo]- -[ Cup]-",
+ "",
+ " If the input to this instruction is false then the output is false. If",
+ " the input is true then the output is true if and only if the given",
+ " condition is true. This instruction can be used to compare (equals,",
+ " is greater than, is greater than or equal to, does not equal,",
+ " is less than, is less than or equal to) a variable to a variable,",
+ " or to compare a variable to a 16-bit signed constant.",
+ "",
+ "",
+ "> COUNTER Cname Cname",
+ " --[CTU >=5]-- --[CTD >=5]--",
+ "",
+ " A counter increments (CTU, count up) or decrements (CTD, count",
+ " down) the associated count on every rising edge of the rung input",
+ " condition (i.e. what the rung input condition goes from false to",
+ " true). The output condition from the counter is true if the counter",
+ " variable is greater than or equal to 5, and false otherwise. The",
+ " rung output condition may be true even if the input condition is",
+ " false; it only depends on the counter variable. You can have CTU",
+ " and CTD instructions with the same name, in order to increment and",
+ " decrement the same counter. The RES instruction can reset a counter,",
+ " or you can perform general variable operations on the count variable.",
+ "",
+ "",
+ "> CIRCULAR COUNTER Cname",
+ " --{CTC 0:7}--",
+ "",
+ " A circular counter works like a normal CTU counter, except that",
+ " after reaching its upper limit, it resets its counter variable",
+ " back to 0. For example, the counter shown above would count 0, 1,",
+ " 2, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7, 0, 2,.... This is useful in",
+ " combination with conditional statements on the variable `Cname';",
+ " you can use this like a sequencer. CTC counters clock on the rising",
+ " edge of the rung input condition condition. This instruction must",
+ " be the rightmost instruction in its rung.",
+ "",
+ "",
+ "> SHIFT REGISTER {SHIFT REG }",
+ " -{ reg0..3 }-",
+ "",
+ " A shift register is associated with a set of variables. For example,",
+ " this shift register is associated with the variables `reg0', `reg1',",
+ " `reg2', and `reg3'. The input to the shift register is `reg0'. On",
+ " every rising edge of the rung-in condition, the shift register will",
+ " shift right. That means that it assigns `reg3 := reg2', `reg2 :=",
+ " reg1'. and `reg1 := reg0'. `reg0' is left unchanged. A large shift",
+ " register can easily consume a lot of memory. This instruction must",
+ " be the rightmost instruction in its rung.",
+ "",
+ "",
+ "> LOOK-UP TABLE {dest := }",
+ " -{ LUT[i] }-",
+ "",
+ " A look-up table is an ordered set of n values. When the rung-in",
+ " condition is true, the integer variable `dest' is set equal to the",
+ " entry in the lookup table corresponding to the integer variable",
+ " `i'. The index starts from zero, so `i' must be between 0 and",
+ " (n-1). The behaviour of this instruction is not defined if the",
+ " index is outside this range. This instruction must be the rightmost",
+ " instruction in its rung.",
+ "",
+ "",
+ "> PIECEWISE LINEAR TABLE {yvar := }",
+ " -{ PWL[xvar] }-",
+ "",
+ " This is a good way to approximate a complicated function or",
+ " curve. It might, for example, be useful if you are trying to apply",
+ " a calibration curve to convert a raw output voltage from a sensor",
+ " into more convenient units.",
+ "",
+ " Assume that you are trying to approximate a function that converts",
+ " an integer input variable, x, to an integer output variable, y. You",
+ " know the function at several points; for example, you might know that",
+ "",
+ " f(0) = 2",
+ " f(5) = 10",
+ " f(10) = 50",
+ " f(100) = 100",
+ "",
+ " This means that the points",
+ "",
+ " (x0, y0) = ( 0, 2)",
+ " (x1, y1) = ( 5, 10)",
+ " (x2, y2) = ( 10, 50)",
+ " (x3, y3) = (100, 100)",
+ "",
+ " lie on that curve. You can enter those 4 points into a table",
+ " associated with the piecewise linear instruction. The piecewise linear",
+ " instruction will look at the value of xvar, and set the value of",
+ " yvar. It will set yvar in such a way that the piecewise linear curve",
+ " will pass through all of the points that you give it; for example,",
+ " if you set xvar = 10, then the instruction will set yvar = 50.",
+ "",
+ " If you give the instruction a value of xvar that lies between two",
+ " of the values of x for which you have given it points, then the",
+ " instruction will set yvar so that (xvar, yvar) lies on the straight",
+ " line connecting those two points in the table. For example, xvar =",
+ " 55 gives an output of yvar = 75. (The two points in the table are",
+ " (10, 50) and (100, 100). 55 is half-way between 10 and 100, and 75",
+ " is half-way between 50 and 100, so (55, 75) lies on the line that",
+ " connects those two points.)",
+ "",
+ " The points must be specified in ascending order by x coordinate. It",
+ " may not be possible to perform mathematical operations required for",
+ " certain look-up tables using 16-bit integer math; if this is the",
+ " case, then LDmicro will warn you. For example, this look up table",
+ " will produce an error:",
+ "",
+ " (x0, y0) = ( 0, 0)",
+ " (x1, y1) = (300, 300)",
+ "",
+ " You can fix these errors by making the distance between points in",
+ " the table smaller. For example, this table is equivalent to the one",
+ " given above, and it does not produce an error:",
+ "",
+ " (x0, y0) = ( 0, 0)",
+ " (x1, y1) = (150, 150)",
+ " (x2, y2) = (300, 300)",
+ "",
+ " It should hardly ever be necessary to use more than five or six",
+ " points. Adding more points makes your code larger and slower to",
+ " execute. The behaviour if you pass a value of `xvar' greater than",
+ " the greatest x coordinate in the table or less than the smallest x",
+ " coordinate in the table is undefined. This instruction must be the",
+ " rightmost instruction in its rung.",
+ "",
+ "",
+ "> A/D CONVERTER READ Aname",
+ " --{READ ADC}--",
+ "",
+ " LDmicro can generate code to use the A/D converters built in to",
+ " certain microcontrollers. If the input condition to this instruction",
+ " is true, then a single sample from the A/D converter is acquired and",
+ " stored in the variable `Aname'. This variable can subsequently be",
+ " manipulated with general variable operations (less than, greater than,",
+ " arithmetic, and so on). Assign a pin to the `Axxx' variable in the",
+ " same way that you would assign a pin to a digital input or output,",
+ " by double-clicking it in the list at the bottom of the screen. If",
+ " the input condition to this rung is false then the variable `Aname'",
+ " is left unchanged.",
+ "",
+ " For all currently-supported devices, 0 volts input corresponds to",
+ " an ADC reading of 0, and an input equal to Vdd (the supply voltage)",
+ " corresponds to an ADC reading of 1023. If you are using an AVR, then",
+ " connect AREF to Vdd. You can use arithmetic operations to scale the",
+ " reading to more convenient units afterwards, but remember that you",
+ " are using integer math. In general not all pins will be available",
+ " for use with the A/D converter. The software will not allow you to",
+ " assign non-A/D pins to an analog input. This instruction must be",
+ " the rightmost instruction in its rung.",
+ "",
+ "",
+ "> SET PWM DUTY CYCLE duty_cycle",
+ " -{PWM 32.8 kHz}-",
+ "",
+ " LDmicro can generate code to use the PWM peripheral built in to",
+ " certain microcontrollers. If the input condition to this instruction",
+ " is true, then the duty cycle of the PWM peripheral is set to the",
+ " value of the variable duty_cycle. The duty cycle must be a number",
+ " between 0 and 100; 0 corresponds to always low, and 100 corresponds to",
+ " always high. (If you are familiar with how the PWM peripheral works,",
+ " then notice that that means that LDmicro automatically scales the",
+ " duty cycle variable from percent to PWM clock periods.)",
+ "",
+ " You can specify the target PWM frequency, in Hz. The frequency that",
+ " you specify might not be exactly achievable, depending on how it",
+ " divides into the microcontroller's clock frequency. LDmicro will",
+ " choose the closest achievable frequency; if the error is large then",
+ " it will warn you. Faster speeds may sacrifice resolution.",
+ "",
+ " This instruction must be the rightmost instruction in its rung.",
+ " The ladder logic runtime consumes one timer to measure the cycle",
+ " time. That means that PWM is only available on microcontrollers",
+ " with at least two suitable timers. PWM uses pin CCP2 (not CCP1)",
+ " on PIC16 chips and OC2 (not OC1A) on AVRs.",
+ "",
+ "",
+ "> MAKE PERSISTENT saved_var",
+ " --{PERSIST}--",
+ "",
+ " When the rung-in condition of this instruction is true, it causes the",
+ " specified integer variable to be automatically saved to EEPROM. That",
+ " means that its value will persist, even when the micro loses",
+ " power. There is no need to explicitly save the variable to EEPROM;",
+ " that will happen automatically, whenever the variable changes. The",
+ " variable is automatically loaded from EEPROM after power-on reset. If",
+ " a variable that changes frequently is made persistent, then the",
+ " EEPROM in your micro may wear out very quickly, because it is only",
+ " good for a limited (~100 000) number of writes. When the rung-in",
+ " condition is false, nothing happens. This instruction must be the",
+ " rightmost instruction in its rung.",
+ "",
+ "",
+ "> UART (SERIAL) RECEIVE var",
+ " --{UART RECV}--",
+ "",
+ " LDmicro can generate code to use the UART built in to certain",
+ " microcontrollers. On AVRs with multiple UARTs only UART1 (not",
+ " UART0) is supported. Configure the baud rate using Settings -> MCU",
+ " Parameters. Certain baud rates may not be achievable with certain",
+ " crystal frequencies; LDmicro will warn you if this is the case.",
+ "",
+ " If the input condition to this instruction is false, then nothing",
+ " happens. If the input condition is true then this instruction tries",
+ " to receive a single character from the UART. If no character is read",
+ " then the output condition is false. If a character is read then its",
+ " ASCII value is stored in `var', and the output condition is true",
+ " for a single PLC cycle.",
+ "",
+ "",
+ "> UART (SERIAL) SEND var",
+ " --{UART SEND}--",
+ "",
+ " LDmicro can generate code to use the UARTs built in to certain",
+ " microcontrollers. On AVRS with multiple UARTs only UART1 (not",
+ " UART0) is supported. Configure the baud rate using Settings -> MCU",
+ " Parameters. Certain baud rates may not be achievable with certain",
+ " crystal frequencies; LDmicro will warn you if this is the case.",
+ "",
+ " If the input condition to this instruction is false, then nothing",
+ " happens. If the input condition is true then this instruction writes",
+ " a single character to the UART. The ASCII value of the character to",
+ " send must previously have been stored in `var'. The output condition",
+ " of the rung is true if the UART is busy (currently transmitting a",
+ " character), and false otherwise.",
+ "",
+ " Remember that characters take some time to transmit. Check the output",
+ " condition of this instruction to ensure that the first character has",
+ " been transmitted before trying to send a second character, or use",
+ " a timer to insert a delay between characters. You must only bring",
+ " the input condition true (try to send a character) when the output",
+ " condition is false (UART is not busy).",
+ "",
+ " Investigate the formatted string instruction (next) before using this",
+ " instruction. The formatted string instruction is much easier to use,",
+ " and it is almost certainly capable of doing what you want.",
+ "",
+ "",
+ "> FORMATTED STRING OVER UART var",
+ " -{\"Pressure: \\3\\r\\n\"}-",
+ "",
+ " LDmicro can generate code to use the UARTs built in to certain",
+ " microcontrollers. On AVRS with multiple UARTs only UART1 (not",
+ " UART0) is supported. Configure the baud rate using Settings -> MCU",
+ " Parameters. Certain baud rates may not be achievable with certain",
+ " crystal frequencies; LDmicro will warn you if this is the case.",
+ "",
+ " When the rung-in condition for this instruction goes from false to",
+ " true, it starts to send an entire string over the serial port. If",
+ " the string contains the special sequence `\\3', then that sequence",
+ " will be replaced with the value of `var', which is automatically",
+ " converted into a string. The variable will be formatted to take",
+ " exactly 3 characters; for example, if `var' is equal to 35, then",
+ " the exact string printed will be `Pressure: 35\\r\\n' (note the extra",
+ " space). If instead `var' were equal to 1432, then the behaviour would",
+ " be undefined, because 1432 has more than three digits. In that case",
+ " it would be necessary to use `\\4' instead.",
+ "",
+ " If the variable might be negative, then use `\\-3d' (or `\\-4d'",
+ " etc.) instead. That will cause LDmicro to print a leading space for",
+ " positive numbers, and a leading minus sign for negative numbers.",
+ "",
+ " If multiple formatted string instructions are energized at once",
+ " (or if one is energized before another completes), or if these",
+ " instructions are intermixed with the UART TX instructions, then the",
+ " behaviour is undefined.",
+ "",
+ " It is also possible to use this instruction to output a fixed string,",
+ " without interpolating an integer variable's value into the text that",
+ " is sent over serial. In that case simply do not include the special",
+ " escape sequence.",
+ "",
+ " Use `\\\\' for a literal backslash. In addition to the escape sequence",
+ " for interpolating an integer variable, the following control",
+ " characters are available:",
+ " * \\r -- carriage return",
+ " * \\n -- newline",
+ " * \\f -- formfeed",
+ " * \\b -- backspace",
+ " * \\xAB -- character with ASCII value 0xAB (hex)",
+ "",
+ " The rung-out condition of this instruction is true while it is",
+ " transmitting data, else false. This instruction consumes a very",
+ " large amount of program memory, so it should be used sparingly. The",
+ " present implementation is not efficient, but a better one will",
+ " require modifications to all the back-ends.",
+ "",
+ "",
+ "A NOTE ON USING MATH",
+ "====================",
+ "",
+ "Remember that LDmicro performs only 16-bit integer math. That means",
+ "that the final result of any calculation that you perform must be an",
+ "integer between -32768 and 32767. It also mean that the intermediate",
+ "results of your calculation must all be within that range.",
+ "",
+ "For example, let us say that you wanted to calculate y = (1/x)*1200,",
+ "where x is between 1 and 20. Then y goes between 1200 and 60, which",
+ "fits into a 16-bit integer, so it is at least in theory possible to",
+ "perform the calculation. There are two ways that you might code this:",
+ "you can perform the reciprocal, and then multiply:",
+ "",
+ " || {DIV temp :=} ||",
+ " ||---------{ 1 / x }----------||",
+ " || ||",
+ " || {MUL y := } ||",
+ " ||----------{ temp * 1200}----------||",
+ " || ||",
+ "",
+ "Or you could just do the division directly, in a single step:",
+ "",
+ " || {DIV y :=} ||",
+ " ||-----------{ 1200 / x }-----------||",
+ "",
+ "Mathematically, these two are equivalent; but if you try them, then you",
+ "will find that the first one gives an incorrect result of y = 0. That",
+ "is because the variable `temp' underflows. For example, when x = 3,",
+ "(1 / x) = 0.333, but that is not an integer; the division operation",
+ "approximates this as temp = 0. Then y = temp * 1200 = 0. In the second",
+ "case there is no intermediate result to underflow, so everything works.",
+ "",
+ "If you are seeing problems with your math, then check intermediate",
+ "results for underflow (or overflow, which `wraps around'; for example,",
+ "32767 + 1 = -32768). When possible, choose units that put values in",
+ "a range of -100 to 100.",
+ "",
+ "When you need to scale a variable by some factor, do it using a multiply",
+ "and a divide. For example, to scale y = 1.8*x, calculate y = (9/5)*x",
+ "(which is the same, since 1.8 = 9/5), and code this as y = (9*x)/5,",
+ "performing the multiplication first:",
+ "",
+ " || {MUL temp :=} ||",
+ " ||---------{ x * 9 }----------||",
+ " || ||",
+ " || {DIV y :=} ||",
+ " ||-----------{ temp / 5 }-----------||",
+ "",
+ "This works for all x < (32767 / 9), or x < 3640. For larger values of x,",
+ "the variable `temp' would overflow. There is a similar lower limit on x.",
+ "",
+ "",
+ "CODING STYLE",
+ "============",
+ "",
+ "I allow multiple coils in parallel in a single rung. This means that",
+ "you can do things like this:",
+ "",
+ " || Xa Ya ||",
+ " 1 ||-------] [--------------( )-------||",
+ " || ||",
+ " || Xb Yb ||",
+ " ||-------] [------+-------( )-------||",
+ " || | ||",
+ " || | Yc ||",
+ " || +-------( )-------||",
+ " || ||",
+ "",
+ "Instead of this:",
+ "",
+ " || Xa Ya ||",
+ " 1 ||-------] [--------------( )-------||",
+ " || ||",
+ " || ||",
+ " || ||",
+ " || ||",
+ " || Xb Yb ||",
+ " 2 ||-------] [--------------( )-------||",
+ " || ||",
+ " || ||",
+ " || ||",
+ " || ||",
+ " || Xb Yc ||",
+ " 3 ||-------] [--------------( )-------||",
+ " || ||",
+ "",
+ "This means that in theory you could write any program as one giant rung,",
+ "and there is no need to use multiple rungs at all. In practice that",
+ "would be a bad idea, because as rungs become more complex they become",
+ "more difficult to edit without deleting and redrawing a lot of logic.",
+ "",
+ "Still, it is often a good idea to group related logic together as a single",
+ "rung. This generates nearly identical code to if you made separate rungs,",
+ "but it shows that they are related when you look at them on the ladder",
+ "diagram.",
+ "",
+ " * * *",
+ "",
+ "In general, it is considered poor form to write code in such a way that",
+ "its output depends on the order of the rungs. For example, this code",
+ "isn't very good if both Xa and Xb might ever be true:",
+ "",
+ " || Xa {v := } ||",
+ " 1 ||-------] [--------{ 12 MOV}--||",
+ " || ||",
+ " || Xb {v := } ||",
+ " ||-------] [--------{ 23 MOV}--||",
+ " || ||",
+ " || ||",
+ " || ||",
+ " || ||",
+ " || [v >] Yc ||",
+ " 2 ||------[ 15]-------------( )-------||",
+ " || ||",
+ "",
+ "I will break this rule if in doing so I can make a piece of code",
+ "significantly more compact, though. For example, here is how I would",
+ "convert a 4-bit binary quantity on Xb3:0 into an integer:",
+ "",
+ " || {v := } ||",
+ " 3 ||-----------------------------------{ 0 MOV}--||",
+ " || ||",
+ " || Xb0 {ADD v :=} ||",
+ " ||-------] [------------------{ v + 1 }-----------||",
+ " || ||",
+ " || Xb1 {ADD v :=} ||",
+ " ||-------] [------------------{ v + 2 }-----------||",
+ " || ||",
+ " || Xb2 {ADD v :=} ||",
+ " ||-------] [------------------{ v + 4 }-----------||",
+ " || ||",
+ " || Xb3 {ADD v :=} ||",
+ " ||-------] [------------------{ v + 8 }-----------||",
+ " || ||",
+ "",
+ "If the MOV statement were moved to the bottom of the rung instead of the",
+ "top, then the value of v when it is read elsewhere in the program would",
+ "be 0. The output of this code therefore depends on the order in which",
+ "the instructions are evaluated. Considering how cumbersome it would be",
+ "to code this any other way, I accept that.",
+ "",
+ "",
+ "BUGS",
+ "====",
+ "",
+ "LDmicro does not generate very efficient code; it is slow to execute, and",
+ "wasteful of flash and RAM. In spite of this, a mid-sized PIC or AVR can",
+ "do everything that a small PLC can, so this does not bother me very much.",
+ "",
+ "The maximum length of variable names is highly limited. This is so that",
+ "they fit nicely onto the ladder diagram, so I don't see a good solution",
+ "to that.",
+ "",
+ "If your program is too big for the time, program memory, or data memory",
+ "constraints of the device that you have chosen then you probably won't",
+ "get an error. It will just screw up somewhere.",
+ "",
+ "Careless programming in the file load/save routines probably makes it",
+ "possible to crash or execute arbitrary code given a corrupt or malicious",
+ ".ld file.",
+ "",
+ "Please report additional bugs or feature requests to the author.",
+ "",
+ "Thanks to:",
+ " * Marcelo Solano, for reporting a UI bug under Win98",
+ " * Serge V. Polubarjev, for not only noticing that RA3:0 on the",
+ " PIC16F628 didn't work but also telling me how to fix it",
+ " * Maxim Ibragimov, for reporting and diagnosing major problems",
+ " with the till-then-untested ATmega16 and ATmega162 targets",
+ " * Bill Kishonti, for reporting that the simulator crashed when the",
+ " ladder logic program divided by zero",
+ " * Mohamed Tayae, for reporting that persistent variables were broken",
+ " on the PIC16F628",
+ " * David Rothwell, for reporting several user interface bugs and a",
+ " problem with the \"Export as Text\" function",
+ "",
+ "",
+ "COPYING, AND DISCLAIMER",
+ "=======================",
+ "",
+ "DO NOT USE CODE GENERATED BY LDMICRO IN APPLICATIONS WHERE SOFTWARE",
+ "FAILURE COULD RESULT IN DANGER TO HUMAN LIFE OR DAMAGE TO PROPERTY. THE",
+ "AUTHOR ASSUMES NO LIABILITY FOR ANY DAMAGES RESULTING FROM THE OPERATION",
+ "OF LDMICRO OR CODE GENERATED BY LDMICRO.",
+ "",
+ "This program is free software: you can redistribute it and/or modify it",
+ "under the terms of the GNU General Public License as published by the",
+ "Free Software Foundation, either version 3 of the License, or (at your",
+ "option) any later version.",
+ "",
+ "This program is distributed in the hope that it will be useful, but",
+ "WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY",
+ "or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License",
+ "for more details.",
+ "",
+ "You should have received a copy of the GNU General Public License along",
+ "with this program. If not, see <http://www.gnu.org/licenses/>.",
+ "",
+ "",
+ "Jonathan Westhues",
+ "",
+ "Rijswijk -- Dec 2004",
+ "Waterloo ON -- Jun, Jul 2005",
+ "Cambridge MA -- Sep, Dec 2005",
+ " Feb, Mar 2006",
+ " Feb 2007",
+ "Seattle WA -- Feb 2009",
+ "",
+ "Email: user jwesthues, at host cq.cx",
+ "",
+ "",
+ NULL
+};
+#endif
+
diff --git a/ldmicro/obj/lang-tables.h b/ldmicro/obj/lang-tables.h new file mode 100644 index 0000000..8b290d6 --- /dev/null +++ b/ldmicro/obj/lang-tables.h @@ -0,0 +1,1568 @@ +#ifdef LDLANG_DE
+static LangTable LangDeTable[] = {
+ { "Target frequency %d Hz, closest achievable is %d Hz (warning, >5%% error).", "Zielfrequenz %d Hz, nächste erreichbare ist %d Hz (Warnung, >5% Abweichung)." },
+ { "Compile successful; wrote IHEX for AVR to '%s'.\r\n\r\nRemember to set the processor configuration (fuses) correctly. This does not happen automatically.", "Kompilierung war erfolgreich. IHEX für AVR gespeichert unter '%s'.\r\n\r\n Die Prozessor-Konfigurationsbits müssen richtig gesetzt werden. Dies geschieht nicht automatisch" },
+ { "( ) Normal", "( ) Normal" },
+ { "(/) Negated", "(/) Negiert" },
+ { "(S) Set-Only", "(S) Setzen" },
+ { "(R) Reset-Only", "(R) Rücksetzen" },
+ { "Pin on MCU", "Prozessorpin" },
+ { "Coil", "Spule" },
+ { "Comment", "Kommentar" },
+ { "Cycle Time (ms):", "Zykluszeit (ms):" },
+ { "Crystal Frequency (MHz):", "Quarzfrequenz (MHz):" },
+ { "UART Baud Rate (bps):", "UART Baudrate (bps):" },
+ { "Serial (UART) will use pins %d and %d.\r\n\r\n", "Serielles (UART) verwendet die Pins %d und %d.\r\n\r\n" },
+ { "Please select a micro with a UART.\r\n\r\n", "Einen Prozessor mit UART wählen.\r\n\r\n" },
+ { "No serial instructions (UART Send/UART Receive) are in use; add one to program before setting baud rate.\r\n\r\n", "Keine UART-Anweisung Senden/Empfangen gefunden; die Baudrate festlegen, wenn diese Anweisung verwendet wird.\r\n\r\n" },
+ { "The cycle time for the 'PLC' runtime generated by LDmicro is user-configurable. Very short cycle times may not be achievable due to processor speed constraints, and very long cycle times may not be achievable due to hardware overflows. Cycle times between 10 ms and 100 ms will usually be practical.\r\n\r\nThe compiler must know what speed crystal you are using with the micro to convert between timing in clock cycles and timing in seconds. A 4 MHz to 20 MHz crystal is typical; check the speed grade of the part you are using to determine the maximum allowable clock speed before choosing a crystal.", "Die von LDmicro erzeugte Zykluszeit des SPS-Ablaufs ist vom Anwender konfigurierbar. Sehr kurze Zykluszeiten können wegen Prozessorbeschränkungen nicht erreichbar sein, und sehr lange Zykluszeiten können wegen Hardware-Überlaufs nicht erreichbar sein. Zykluszeiten zwischen 10 ms und 100 ms sind üblich.\r\n\r\nFür die Umrechnung des Taktzykluses und der Zeitberechnung in Sekunden, muss der Compiler wissen, welche Quarzfrequenz beim Prozessor verwendet wird. Ein Quarz mit 4 bis 20 MHz ist üblich; Überprüfen Sie die Geschwindigkeit Ihres Prozessors, um die maximal erlaubte Taktgeschwindigkeit zu bestimmen, bevor Sie einen Quarz wählen." },
+ { "PLC Configuration", "SPS-Konfiguration" },
+ { "Zero cycle time not valid; resetting to 10 ms.", "Zykluszeit = 0, nicht zulässig; wird auf 10 ms gesetzt." },
+ { "Source", "Quelle" },
+ { "Internal Relay", "Merker" },
+ { "Input pin", "Eingangspin" },
+ { "Output pin", "Ausgangspin" },
+ { "|/| Negated", "|/| Negiert" },
+ { "Contacts", "Kontakte" },
+ { "No ADC or ADC not supported for selected micro.", "Kein A/D-Wandler vorhanden oder A/D-Wandler wird vom gewählten Prozessor nicht unterstützt." },
+ { "Assign:", "Zuweisen:" },
+ { "No microcontroller has been selected. You must select a microcontroller before you can assign I/O pins.\r\n\r\nSelect a microcontroller under the Settings menu and try again.", "Kein Prozessor gewählt. Sie müssen einen Prozessor wählen, bevor Sie E/A Pins zuweisen können.\r\n\r\nWählen Sie einen Prozessor im Voreinstellungs-Menu und versuchen es noch mal." },
+ { "I/O Pin Assignment", "E/A Pin Zuweisung" },
+ { "Can't specify I/O assignment for ANSI C target; compile and see comments in generated source code.", "Keine E/A Zuweisung für ANSI C-Ziel möglich; kompilieren Sie und beachten die Kommentare im erzeugten Quellcode." },
+ { "Can't specify I/O assignment for interpretable target; see comments in reference implementation of interpreter.", "Keine E/A Zuweisung für ANSI C-Ziel möglich; beachten Sie die Kommentare der Referenz-Ausführung des Interpreters." },
+ { "Can only assign pin number to input/output pins (Xname or Yname or Aname).", "Nur für Ein- und Ausgangspins können Pin-Nummern vergeben werden (XName oder YName oder AName)." },
+ { "No ADC or ADC not supported for this micro.", "Kein A/D-Wandler vorhanden oder A/D-Wandler wird vom gewählten Prozessor nicht unterstützt." },
+ { "Rename I/O from default name ('%s') before assigning MCU pin.", "Die Standardbezeichnung ('%s') des E/A’s vor der Zuweisung des Prozessorpins ändern." },
+ { "I/O Pin", "E/A Pin" },
+ { "(no pin)", "(kein Pin)" },
+ { "<UART needs!>", "<UART benötigt!>" },
+ { "<PWM needs!>", "<PWM benötigt!>" },
+ { "<not an I/O!>", "<kein E/A!>" },
+ { "Export As Text", "Als Text exportieren" },
+ { "Couldn't write to '%s'.", "Speichern nicht möglich unter '%s'." },
+ { "Compile To", "Kompilieren unter" },
+ { "Must choose a target microcontroller before compiling.", "Vor dem Kompilieren muss ein Prozessor gewählt werden." },
+ { "UART function used but not supported for this micro.", "Dieser Prozessor unterstützt keine UART-Funktion." },
+ { "PWM function used but not supported for this micro.", "Dieser Prozessor unterstützt keine PWM-Funktion." },
+ { "The program has changed since it was last saved.\r\n\r\nDo you want to save the changes?", "Das Programm wurde nach dem letzten Speichern geändert.\r\n\r\n Möchten Sie die Änderungen speichern?" },
+ { "--add comment here--", "--Hier Komentar einfügen--" },
+ { "Start new program?", "Neues Programm starten?" },
+ { "Couldn't open '%s'.", "Kann nicht geöffnet werden '%s'." },
+ { "Name", "Name" },
+ { "State", "Status" },
+ { "Pin on Processor", "Prozessorpin" },
+ { "MCU Port", "Prozessor-Port" },
+ { "LDmicro - Simulation (Running)", "LDmicro - Simulation (am Laufen)" },
+ { "LDmicro - Simulation (Stopped)", "LDmicro - Simulation (Angehalten)" },
+ { "LDmicro - Program Editor", "LDmicro – Programm-Editor" },
+ { " - (not yet saved)", " - (noch nicht gespeichert)" },
+ { "&New\tCtrl+N", "&Neu\tStrg+N" },
+ { "&Open...\tCtrl+O", "&Öffnen...\tStrg+O" },
+ { "&Save\tCtrl+S", "&Speichern\tStrg+S" },
+ { "Save &As...", "Speichern &unter..." },
+ { "&Export As Text...\tCtrl+E", "&Als Text exportieren...\tStrg+E" },
+ { "E&xit", "&Beenden" },
+ { "&Undo\tCtrl+Z", "&Aufheben\tStrg+Z" },
+ { "&Redo\tCtrl+Y", "&Wiederherstellen\tStrg+Y" },
+ { "Insert Rung &Before\tShift+6", "Netzwerk Einfügen &Davor\tShift+6" },
+ { "Insert Rung &After\tShift+V", "Netzwerk Einfügen &Danach\tShift+V" },
+ { "Move Selected Rung &Up\tShift+Up", "Gewähltes Netzwerk schieben &nach oben\tShift+Up" },
+ { "Move Selected Rung &Down\tShift+Down", "Gewähltes Netzwerk schieben &nach unten\tShift+Down" },
+ { "&Delete Selected Element\tDel", "&Gewähltes Element löschen\tEntf" },
+ { "D&elete Rung\tShift+Del", "Netzwerk löschen\tShift+Entf" },
+ { "Insert Co&mment\t;", "Kommentar &einfügen\t;" },
+ { "Insert &Contacts\tC", "Kontakt &einfügen\tC" },
+ { "Insert OSR (One Shot Rising)\t&/", "OSR einfügen (Steigende Flanke)\t&/" },
+ { "Insert OSF (One Shot Falling)\t&\\", "OSF einfügen (Fallende Flanke)\t&\\" },
+ { "Insert T&ON (Delayed Turn On)\tO", "T&ON einfügen (Anzugsverzögerung)\tO" },
+ { "Insert TO&F (Delayed Turn Off)\tF", "TO&F einfügen (Abfallverzögerung)\tF" },
+ { "Insert R&TO (Retentive Delayed Turn On)\tT", "R&TO einfügen (Speichernde Anzugsverzögerung)\tT" },
+ { "Insert CT&U (Count Up)\tU", "CT&U einfügen (Aufwärtszähler)\tU" },
+ { "Insert CT&D (Count Down)\tI", "CT&D einfügen (Abwärtszähler)\tI" },
+ { "Insert CT&C (Count Circular)\tJ", "CT&C einfügen (Zirkulierender Zähler)\tJ" },
+ { "Insert EQU (Compare for Equals)\t=", "EQU einfügen (Vergleich auf gleich)\t=" },
+ { "Insert NEQ (Compare for Not Equals)", "NEQ einfügen (Vergleich auf ungleich)" },
+ { "Insert GRT (Compare for Greater Than)\t>", "GRT einfügen (Vergleich auf größer)\t>" },
+ { "Insert GEQ (Compare for Greater Than or Equal)\t.", "GEQ einfügen (Vergleich auf größer oder gleich)\t." },
+ { "Insert LES (Compare for Less Than)\t<", "LES einfügen (Vergleich auf kleiner)\t<" },
+ { "Insert LEQ (Compare for Less Than or Equal)\t,", "LEQ einfügen (Vergleich auf kleiner oder gleich)\t," },
+ { "Insert Open-Circuit", "Öffnung einfügen" },
+ { "Insert Short-Circuit", "Brücke einfügen" },
+ { "Insert Master Control Relay", "Master Control Relais einfügen" },
+ { "Insert Coi&l\tL", "Spule einfügen \tL" },
+ { "Insert R&ES (Counter/RTO Reset)\tE", "R&ES einfügen (RTO/Zähler rücksetzen)\tE" },
+ { "Insert MOV (Move)\tM", "Transferieren (Move) einfügen\tM" },
+ { "Insert ADD (16-bit Integer Add)\t+", "ADD einfügen (16-bit Ganzzahl Addierer)\t+" },
+ { "Insert SUB (16-bit Integer Subtract)\t-", "SUB einfügen (16-bit Ganzzahl Subtrahierer)\t-" },
+ { "Insert MUL (16-bit Integer Multiply)\t*", "MUL einfügen (16-bit Ganzzahl Multiplizierer)\t*" },
+ { "Insert DIV (16-bit Integer Divide)\tD", "DIV einfügen (16-bit Ganzzahl Dividierer)\tD" },
+ { "Insert Shift Register", "Schieberegister einfügen" },
+ { "Insert Look-Up Table", "Nachschlag-Tabelle einfügen" },
+ { "Insert Piecewise Linear", "Näherungs-Linear-Tabelle einfügen" },
+ { "Insert Formatted String Over UART", "Formatierte Zeichenfolge über UART einfügen" },
+ { "Insert &UART Send", "&UART Senden einfügen" },
+ { "Insert &UART Receive", "&UART Empfangen einfügen" },
+ { "Insert Set PWM Output", "PWM Ausgang einfügen" },
+ { "Insert A/D Converter Read\tP", "A/D-Wandler Einlesen einfügen\tP" },
+ { "Insert Make Persistent", "Remanent machen einfügen" },
+ { "Make Norm&al\tA", "Auf Normal ändern\tA" },
+ { "Make &Negated\tN", "Auf &Negieren ändern\tN" },
+ { "Make &Set-Only\tS", "Auf &Setzen ändern\tS" },
+ { "Make &Reset-Only\tR", "Auf &Rücksetzen ändern\tR" },
+ { "&MCU Parameters...", "&Prozessor-Parameter..." },
+ { "(no microcontroller)", "(kein Prozessor)" },
+ { "&Microcontroller", "&Mikroprozessor" },
+ { "Si&mulation Mode\tCtrl+M", "Simulationsbetrieb\tStrg+M" },
+ { "Start &Real-Time Simulation\tCtrl+R", "Start &Echtzeit- Simulation\tStrg+R" },
+ { "&Halt Simulation\tCtrl+H", "&Simulation Anhalten\tStrg+H" },
+ { "Single &Cycle\tSpace", "&Einzelzyklus\tLeertaste" },
+ { "&Compile\tF5", "&Kompilieren\tF5" },
+ { "Compile &As...", "Kompilieren &unter..." },
+ { "&Manual...\tF1", "&Handbuch...\tF1" },
+ { "&About...", "&Über LDmicro..." },
+ { "&File", "&Datei" },
+ { "&Edit", "&Bearbeiten" },
+ { "&Settings", "&Voreinstellungen" },
+ { "&Instruction", "&Anweisung" },
+ { "Si&mulate", "Simulieren" },
+ { "&Compile", "&Kompilieren" },
+ { "&Help", "&Hilfe" },
+ { "no MCU selected", "kein Prozessor gewählt" },
+ { "cycle time %.2f ms", "Zykluszeit %.2f ms" },
+ { "processor clock %.4f MHz", "Taktfrequenz Prozessor %.4f MHz" },
+ { "Internal error relating to PIC paging; make program smaller or reshuffle it.", "Interner Fehler beim PIC paging Seitenwechsel; Programm verkleinern oder umbilden" },
+ { "PWM frequency too fast.", "PWM Frequenz zu schnell." },
+ { "PWM frequency too slow.", "PWM Frequenz zu langsam." },
+ { "Cycle time too fast; increase cycle time, or use faster crystal.", "Zykluszeit zu schnell; Zykluszeit vergrößern oder schnelleren Quarz wählen." },
+ { "Cycle time too slow; decrease cycle time, or use slower crystal.", "Zykluszeit zu langsam; Zykluszeit verringern oder langsameren Quarz wählen." },
+ { "Couldn't open file '%s'", "Datei konnte nicht geöffnet werden '%s'" },
+ { "Zero baud rate not possible.", "Baudrate = 0 nicht möglich" },
+ { "Compile successful; wrote IHEX for PIC16 to '%s'.\r\n\r\nConfiguration word (fuses) has been set for crystal oscillator, BOD enabled, LVP disabled, PWRT enabled, all code protection off.\r\n\r\nUsed %d/%d words of program flash (chip %d%% full).", "Kompilierung war erfolgreich; IHEX für PIC16 gespeichert unter '%s'.\r\n\r\nKonfigurations-Wort (fuse) für Quarz-Oszillator festgelegt, BOD aktiviert, LVP gesperrt, PWRT aktiviert, Verschlüsselungsschutz aus.\r\n\r\nVerwendete %d/%d Worte des Flash-Speichers (Chip %d%% voll)." },
+ { "Type", "Typ" },
+ { "Timer", "Timer" },
+ { "Counter", "Zähler" },
+ { "Reset", "Rücksetzen" },
+ { "OK", "OK" },
+ { "Cancel", "Abbrechen" },
+ { "Empty textbox; not permitted.", "Leere Testbox; nicht erlaubt" },
+ { "Bad use of quotes: <%s>", "Quoten falsch verwendet: <%s>" },
+ { "Turn-On Delay", "Anzugsverzögerung" },
+ { "Turn-Off Delay", "Abfallverzögerung" },
+ { "Retentive Turn-On Delay", "Speichernde Anzugsverzögerung" },
+ { "Delay (ms):", "Verzögerung (ms):" },
+ { "Delay too long; maximum is 2**31 us.", "Verzögerung zu lang; maximal 2**31 us." },
+ { "Delay cannot be zero or negative.", "Verzögerung kann nicht gleich Null oder negativ sein." },
+ { "Count Up", "Aufwärtszählen" },
+ { "Count Down", "Abwärtszählen" },
+ { "Circular Counter", "Zirkulierender Zähler" },
+ { "Max value:", "Maximalwert:" },
+ { "True if >= :", "Wahr wenn >= :" },
+ { "If Equals", "Wenn gleich" },
+ { "If Not Equals", "Wenn ungleich" },
+ { "If Greater Than", "Wenn größer als" },
+ { "If Greater Than or Equal To", "Wenn größer als oder gleich" },
+ { "If Less Than", "Wenn kleiner als" },
+ { "If Less Than or Equal To", "Wenn kleiner als oder gleich" },
+ { "'Closed' if:", "'Geschlossen' wenn:" },
+ { "Move", "Transferieren" },
+ { "Read A/D Converter", "A/D-Wandler einlesen" },
+ { "Duty cycle var:", "Einsatzzyklus Var:" },
+ { "Frequency (Hz):", "Frequenz (Hz):" },
+ { "Set PWM Duty Cycle", "PWM Einsatzzyklus eingeben" },
+ { "Source:", "Quelle:" },
+ { "Receive from UART", "Mit UART empfangen" },
+ { "Send to UART", "Mit UART senden" },
+ { "Add", "Addieren" },
+ { "Subtract", "Subtrahieren" },
+ { "Multiply", "Multiplizieren" },
+ { "Divide", "Dividieren" },
+ { "Destination:", "Ziel:" },
+ { "is set := :", "gesetzt auf := :" },
+ { "Name:", "Name:" },
+ { "Stages:", "Stufen:" },
+ { "Shift Register", "Schieberegister" },
+ { "Not a reasonable size for a shift register.", "Kein angemessenes Format für ein Schieberegister." },
+ { "String:", "Zeichensatz:" },
+ { "Formatted String Over UART", "Formatierter Zeichensatz über UART" },
+ { "Variable:", "Variable:" },
+ { "Make Persistent", "Remanent machen" },
+ { "Too many elements in subcircuit!", "Zu viele Elemente im Netzwerk!" },
+ { "Too many rungs!", "Zu viele Netzwerke!" },
+ { "Error", "Fehler" },
+ { "ANSI C target does not support peripherals (UART, PWM, ADC, EEPROM). Skipping that instruction.", "ANSI C Zieldatei unterstützt keine Peripherien (wie UART, ADC, EEPROM). Die Anweisung wird ausgelassen." },
+ { "Compile successful; wrote C source code to '%s'.\r\n\r\nThis is not a complete C program. You have to provide the runtime and all the I/O routines. See the comments in the source code for information about how to do this.", "Die Kompilierung war erfolgreich; der C-Quellcode wurde gespeichert unter '%s'.\r\n\r\nDies ist kein komplettes C-Programm. Sie müssen die Laufzeit und alle E/A Routinen vorgeben. Siehe die Kommentare im Quellcode für Informationen, wie man das macht." },
+ { "Cannot delete rung; program must have at least one rung.", "Das Netzwerk nicht löschbar, das Programm muss mindestens ein Netzwerk haben." },
+ { "Out of memory; simplify program or choose microcontroller with more memory.", "Speicher voll; vereinfachen Sie das Programm oder wählen Sie einen Prozessor mit mehr Speicherkapazität." },
+ { "Must assign pins for all ADC inputs (name '%s').", "Für alle ADC-Eingänge müssen Pins zugewiesen werden (Name '%s')." },
+ { "Internal limit exceeded (number of vars)", "Interne Begrenzung überschritten (Anzahl der Variablen)" },
+ { "Internal relay '%s' never assigned; add its coil somewhere.", "Keine Zuweisung für Merker '%s', vergeben Sie eine Spule im Programm." },
+ { "Must assign pins for all I/O.\r\n\r\n'%s' is not assigned.", "Für alle E/A's müssen Pins zugewiesen werden.\r\n\r\n'%s' ist nicht zugewiesen." },
+ { "UART in use; pins %d and %d reserved for that.", "UART in Verwendung; Pins %d und %d sind hierfür reserviert." },
+ { "PWM in use; pin %d reserved for that.", "PWM in Verwendung; Pin %d hierfür reserviert." },
+ { "UART baud rate generator: divisor=%d actual=%.4f for %.2f%% error.\r\n\r\nThis is too large; try a different baud rate (slower probably), or a crystal frequency chosen to be divisible by many common baud rates (e.g. 3.6864 MHz, 14.7456 MHz).\r\n\r\nCode will be generated anyways but serial may be unreliable or completely broken.", "UART Baudraten-Generator: Divisor=%d aktuell=%.4f für %.2f%% Fehler.\r\n\r\nDiese ist zu hoch; versuchen Sie es mit einer anderen Baudrate (wahrscheinlich langsamer), oder eine Quarzfrequenz wählen die von vielen üblichen Baudraten teilbar ist (wie 3.6864MHz, 14.7456MHz).\r\n\r\nCode wird trotzdem erzeugt, aber er kann unzuverlässig oder beschädigt sein." },
+ { "UART baud rate generator: too slow, divisor overflows. Use a slower crystal or a faster baud rate.\r\n\r\nCode will be generated anyways but serial will likely be completely broken.", "UART Baudraten-Generator: Zu langsam, der Divisor hat Überlauf. Einen langsameren Quarz oder schnellere Baudrate verwenden.\r\n\r\nCode wird trotzdem erzeugt, aber er wird wahrscheinlich beschädigt sein." },
+ { "Couldn't open '%s'\n", "Konnte nicht geöffnet werden '%s'\n" },
+ { "Timer period too short (needs faster cycle time).", "Timer-Intervall zu kurz (schnellere Zykluszeit nötig)." },
+ { "Timer period too long (max 32767 times cycle time); use a slower cycle time.", "Timer-Intervall zu lang (max. 32767mal die Zykluszeit); langsamere Zykluszeit verwenden." },
+ { "Constant %d out of range: -32768 to 32767 inclusive.", "Konstante %d außerhalb des Bereichs: -32768 bis 32767 inklusive." },
+ { "Move instruction: '%s' not a valid destination.", "Transfer-Anweisung: '%s' ist keine gültige Zieladresse." },
+ { "Math instruction: '%s' not a valid destination.", "Mathem. Anweisung: '%s'keine gültige Zieladresse." },
+ { "Piecewise linear lookup table with zero elements!", "Näherungs-Linear-Tabelle ohne Elemente!" },
+ { "x values in piecewise linear table must be strictly increasing.", "Die x-Werte in der Näherungs-Linear-Tabelle müssen strikt aufsteigend sein." },
+ { "Numerical problem with piecewise linear lookup table. Either make the table entries smaller, or space the points together more closely.\r\n\r\nSee the help file for details.", "Zahlenmäßiges Problem mit der Näherungs-Linear-Tabelle. Entweder die Eingangswerte der Tabelle verringern, oder die Punkte näher zusammen legen.\r\n\r\nFür Details siehe unter Hilfe." },
+ { "Multiple escapes (\\0-9) present in format string, not allowed.", "Mehrfacher Zeilenumbruch (\\0-9)in formatierter Zeichenfolge nicht gestattet." },
+ { "Bad escape: correct form is \\xAB.", "Falscher Zeilenumbruch: Korrekte Form = \\xAB." },
+ { "Bad escape '\\%c'", "Falscher Zeilenumbruch '\\%c'" },
+ { "Variable is interpolated into formatted string, but none is specified.", "Formatierte Zeichenfolge enthält Variable, aber keine ist angegeben." },
+ { "No variable is interpolated into formatted string, but a variable name is specified. Include a string like '\\-3', or leave variable name blank.", "Keine Variable in formatierter Zeichenfolge eingefügt, aber ein Variabelen-Name wurde vergeben. Geben Sie eine Zeichenfolge ein, wie z.B. '\\-3', oder den Variabelen-Namen unausgefüllt lassen." },
+ { "Empty row; delete it or add instructions before compiling.", "Leere Reihe; vor dem Kompilieren löschen oder Anweisungen einfügen." },
+ { "Couldn't write to '%s'", "Nicht möglich, speichern unter '%s'." },
+ { "Unsupported op (anything ADC, PWM, UART, EEPROM) for interpretable target.", "Keine unterstützte Operation der interpretierbaren Zieldatei (kein ADC, PWM, UART, EEPROM möglich)." },
+ { "Compile successful; wrote interpretable code to '%s'.\r\n\r\nYou probably have to adapt the interpreter to your application. See the documentation.", "Kompilierung war erfolgreich; interpretierbarer Code gespeichert unter '%s'.\r\n\r\nWahrscheinlich müssen Sie den Interpreter an Ihre Anwendung anpassen. Siehe Dokumentation." },
+ { "Microcontroller '%s' not supported.\r\n\r\nDefaulting to no selected MCU.", "Prozessor '%s' nicht unterstützt.\r\n\r\nZurück zu: Kein Prozessor gewählt." },
+ { "File format error; perhaps this program is for a newer version of LDmicro?", "Fehler beim Dateiformat; vielleicht ist dies ein Programm für eine neuere Version von LDmicro." },
+ { "Index:", "Liste:" },
+ { "Points:", "Punkte:" },
+ { "Count:", "Berechnung:" },
+ { "Edit table of ASCII values like a string", "ASCII-Werte Tabelle als Zeichenfolge ausgeben" },
+ { "Look-Up Table", "Nachschlag-Tabelle" },
+ { "Piecewise Linear Table", "Näherungs-Linear-Tabelle" },
+ { "LDmicro Error", "Fehler LDmicro" },
+ { "Compile Successful", "Kompilierung war erfolgreich" },
+ { "digital in", "Digitaler Eingang" },
+ { "digital out", "Digitaler Ausgang" },
+ { "int. relay", "Merker" },
+ { "UART tx", "UART tx" },
+ { "UART rx", "UART rx" },
+ { "PWM out", "PWM Ausgang" },
+ { "turn-on delay", "Anzugsverzögerung" },
+ { "turn-off delay", "Abfallverzögerung" },
+ { "retentive timer", "Speichernder Timer" },
+ { "counter", "Zähler" },
+ { "general var", "Allg. Variable" },
+ { "adc input", "ADC Eingang" },
+ { "<corrupt!>", "<beschädigt!>" },
+ { "(not assigned)", "(nicht zugewiesen)" },
+ { "<no UART!>", "<kein UART!>" },
+ { "<no PWM!>", "<kein PWM!>" },
+ { "TOF: variable cannot be used elsewhere", "TOF: Variable kann andernorts nicht verwendet werden" },
+ { "TON: variable cannot be used elsewhere", "TON: Variable kann andernorts nicht verwendet werden" },
+ { "RTO: variable can only be used for RES elsewhere", "RTO: Variable kann andernorts nur für RES verwendet werden" },
+ { "Variable '%s' not assigned to, e.g. with a MOV statement, an ADD statement, etc.\r\n\r\nThis is probably a programming error; now it will always be zero.", "Variable '%s' nicht zugewiesen, z.B. zu einer Transfer- oder ADD-Anweisung usw.\r\n\r\nDas ist vermutlich ein Programmierungsfehler; jetzt wird sie immer Null sein." },
+ { "Variable for '%s' incorrectly assigned: %s.", "Variable für '%s' falsch zugewiesen: %s." },
+ { "Division by zero; halting simulation", "Division durch Null; Simulation gestoppt" },
+ { "!!!too long!!!", " !!!zu lang!!!" },
+ { "\n\nI/O ASSIGNMENT:\n\n", "\n\nE/A Zuweisungen:\n\n" },
+ { " Name | Type | Pin\n", " Name | Typ | Pin\n" },
+};
+static Lang LangDe = {
+ LangDeTable, sizeof(LangDeTable)/sizeof(LangDeTable[0])
+};
+#endif
+#ifdef LDLANG_ES
+static LangTable LangEsTable[] = {
+ { "Target frequency %d Hz, closest achievable is %d Hz (warning, >5%% error).", "Frecuencia Micro %d Hz, la mejor aproximación es %d Hz (aviso, >5%% error)." },
+ { "Compile successful; wrote IHEX for AVR to '%s'.\r\n\r\nRemember to set the processor configuration (fuses) correctly. This does not happen automatically.", "Compilación correcta; se escribió IHEX para AVR en '%s'.\r\n\r\nRecuerde marcar la configuración (fuses) del micro correctamente. Esto NO se hace automaticamente." },
+ { "( ) Normal", "( ) Normal" },
+ { "(/) Negated", "(/) Negado" },
+ { "(S) Set-Only", "(S) Activar" },
+ { "(R) Reset-Only", "(R) Desactivar" },
+ { "Pin on MCU", "Pata del Micro" },
+ { "Coil", "Bobina" },
+ { "Comment", "Comentario" },
+ { "Cycle Time (ms):", "Tiempo Ciclo (ms):" },
+ { "Crystal Frequency (MHz):", "Frecuencia Cristal (MHz):" },
+ { "UART Baud Rate (bps):", "Baudios UART (bps):" },
+ { "Serie (UART) will use pins %d and %d.\r\n\r\n", "Puerto Serie (UART) usará las patas %d y %d.\r\n\r\n" },
+ { "Please select a micro with a UART.\r\n\r\n", "Por favor. Seleccione un micro con UART.\r\n\r\n" },
+ { "No serial instructions (UART Send/UART Receive) are in use; add one to program before setting baud rate.\r\n\r\n", "No se han usado instrucciones (UART Enviar/UART Recibir) para el puerto serie aun; Añada una al programa antes de configurar los baudios.\r\n\r\n" },
+ { "The cycle time for the 'PLC' runtime generated by LDmicro is user-configurable. Very short cycle times may not be achievable due to processor speed constraints, and very long cycle times may not be achievable due to hardware overflows. Cycle times between 10 ms and 100 ms will usually be practical.\r\n\r\nThe compiler must know what speed crystal you are using with the micro to convert between timing in clock cycles and timing in seconds. A 4 MHz to 20 MHz crystal is typical; check the speed grade of the part you are using to determine the maximum allowable clock speed before choosing a crystal.", "El tiempo de ciclo de ejecución para el 'PLC' es configurable. Un tiempo de ciclo muy corto puede no funcionar debido a la baja velocidad del micro, y un tiempo de ciclo muy largo puede no funcionar por limitaciones del temporizador del micro. Ciclos de tiempo entre 10 y 100 ms suele ser lo normal.\r\n\r\nEl compilador debe conocer la velocidad del cristal que estas usando para poder convertir entre tiempo en ciclos de reloj y tiempo en segundos. Un cristal entre 4 Mhz y 20 Mhz es lo típico; Comprueba la velocidad a la que puede funcionar tu micro y calcula la velocidad máxima del reloj antes de elegir el cristal." },
+ { "PLC Configuration", "Configuración PLC" },
+ { "Zero cycle time not valid; resetting to 10 ms.", "No es valido un tiempo de ciclo 0; forzado a 10 ms." },
+ { "Source", "Fuente" },
+ { "Internal Relay", "Rele Interno" },
+ { "Input pin", "Pata Entrada" },
+ { "Output pin", "Pata Salida" },
+ { "|/| Negated", "|/| Negado" },
+ { "Contacts", "Contacto" },
+ { "No ADC or ADC not supported for selected micro.", "El micro seleccionado no tiene ADC o no esta soportado." },
+ { "Assign:", "Asignar:" },
+ { "No microcontroller has been selected. You must select a microcontroller before you can assign I/O pins.\r\n\r\nSelect a microcontroller under the Settings menu and try again.", "No se ha seleccionado micro. Debes seleccionar un micro antes de asignar patas E/S.\r\n\r\nElije un micro en el menu de configuración y prueba otra vez." },
+ { "I/O Pin Assignment", "Asignación de pata E/S" },
+ { "Can't specify I/O assignment for ANSI C target; compile and see comments in generated source code.", "No se puede asignar la E/S especificadas para el ANSI C generado; compile y vea los comentarios generados en el código fuente." },
+ { "Can't specify I/O assignment for interpretable target; see comments in reference implementation of interpreter.", "No se puede asignar la E/S especificadas para el código generado para el interprete; vea los comentarios en la implementación del interprete." },
+ { "Can only assign pin number to input/output pins (Xname or Yname or Aname).", "Solo puede asignar numero de pata a las patas de Entrada/Salida (Xname o Yname o Aname)." },
+ { "No ADC or ADC not supported for this micro.", "Este micro no tiene ADC o no esta soportado." },
+ { "Rename I/O from default name ('%s') before assigning MCU pin.", "Cambie el nombre por defecto ('%s') antes de asignarle una pata del micro." },
+ { "I/O Pin", "E/S Pata" },
+ { "(no pin)", "(falta pata)" },
+ { "<UART needs!>", "<Se necesita UART!>" },
+ { "<PWM needs!>", "<Se necesita PWM!>" },
+ { "<not an I/O!>", "<No es una E/S!>" },
+ { "Export As Text", "Exportar como Texto" },
+ { "Couldn't write to '%s'.", "No puedo escribir en '%s'." },
+ { "Compile To", "Compilar" },
+ { "Must choose a target microcontroller before compiling.", "Debe elegir un micro antes de compilar." },
+ { "UART function used but not supported for this micro.", "Usadas Funciones para UART. Este micro no las soporta." },
+ { "PWM function used but not supported for this micro.", "Usadas Funciones para PWM. Este micro no las soporta." },
+ { "The program has changed since it was last saved.\r\n\r\nDo you want to save the changes?", "El programa ha cambiado desde la última vez que los guardo.\r\n\r\n¿Quieres guardar los cambios?" },
+ { "--add comment here--", "--añade el comentario aquí--" },
+ { "Start new program?", "¿Empezar un nuevo programa?" },
+ { "Couldn't open '%s'.", "No puedo abrir '%s'." },
+ { "Name", "Nombre" },
+ { "State", "Estado" },
+ { "Pin on Processor", "Pata del Micro" },
+ { "MCU Port", "Puerto del Micro" },
+ { "LDmicro - Simulation (Running)", "LDmicro - Simulación (Ejecutando)" },
+ { "LDmicro - Simulation (Stopped)", "LDmicro - Simulación (Parada)" },
+ { "LDmicro - Program Editor", "LDmicro – Editor de Programa" },
+ { " - (not yet saved)", " - (no guardado aún)" },
+ { "&New\tCtrl+N", "&Nuevo\tCtrl+N" },
+ { "&Open...\tCtrl+O", "&Abrir...\tCtrl+O" },
+ { "&Save\tCtrl+S", "&Guardar\tCtrl+S" },
+ { "Save &As...", "Guardar &Como..." },
+ { "&Export As Text...\tCtrl+E", "&Exportar a Texto...\tCtrl+E" },
+ { "E&xit", "&Salir" },
+ { "&Undo\tCtrl+Z", "&Deshacer\tCtrl+Z" },
+ { "&Redo\tCtrl+Y", "&Rehacer\tCtrl+Y" },
+ { "Insert Rung &Before\tShift+6", "Insertar Línea (Rung) &Antes\tShift+6" },
+ { "Insert Rung &After\tShift+V", "Insertar Línea (Rung) &Despues\tShift+V" },
+ { "Move Selected Rung &Up\tShift+Up", "Subir Línea (Rung) Seleccionada\tShift+Up" },
+ { "Move Selected Rung &Down\tShift+Down", "Bajar Línea (Rung) Seleccionada\tShift+Down" },
+ { "&Delete Selected Element\tDel", "&Borrar Elemento Seleccionado\tSupr" },
+ { "D&elete Rung\tShift+Del", "B&orrar Línea (Rung) Seleccionada\tShift+Supr" },
+ { "Insert Co&mment\t;", "Insertar Co&mentario\t;" },
+ { "Insert &Contacts\tC", "Insertar &Contacto\tC" },
+ { "Insert OSR (One Shot Rising)\t&/", "Insertar OSR (Flanco de Subida)\t&/" },
+ { "Insert OSF (One Shot Falling)\t&\\", "Insertar OSF (Flanco de Bajada)\t&\\" },
+ { "Insert T&ON (Delayed Turn On)\tO", "Insertar T&ON (Encendido Retardado)\tO" },
+ { "Insert TO&F (Delayed Turn Off)\tF", "Insertar TO&F (Apagado Retardado)\tF" },
+ { "Insert R&TO (Retentive Delayed Turn On)\tT", "Insertar R&TO (Encendido Retardado con Memoria)\tT" },
+ { "Insert CT&U (Count Up)\tU", "Insertar CT&U (Contador Incremental)\tU" },
+ { "Insert CT&D (Count Down)\tI", "Insertar CT&D (Contador Decremental)\tI" },
+ { "Insert CT&C (Count Circular)\tJ", "Insertar CT&C (Contador Circular)\tJ" },
+ { "Insert EQU (Compare for Equals)\t=", "Insertar EQU (Comparador si Igual)\t=" },
+ { "Insert NEQ (Compare for Not Equals)", "Insertar NEQ (Comparador si NO Igual)" },
+ { "Insert GRT (Compare for Greater Than)\t>", "Insertar GRT (Comparador si Mayor que)\t>" },
+ { "Insert GEQ (Compare for Greater Than or Equal)\t.", "Insertar GEQ (Comparador si Mayor o Igual que)\t." },
+ { "Insert LES (Compare for Less Than)\t<", "Insertar LES (Comparador si Menor que)\t<" },
+ { "Insert LEQ (Compare for Less Than or Equal)\t,", "Insertar LEQ (Comparador si Menor o Igual que)\t," },
+ { "Insert Open-Circuit", "Insertar Circuito-Abierto" },
+ { "Insert Short-Circuit", "Insertar Circuito-Cerrado" },
+ { "Insert Master Control Relay", "Insertar Rele de Control Maestro" },
+ { "Insert Coi&l\tL", "Insertar &Bobina\tL" },
+ { "Insert R&ES (Counter/RTO Reset)\tE", "Insertar R&ES (Contador/RTO Reinicio)\tE" },
+ { "Insert MOV (Move)\tM", "Insertar MOV (Mover)\tM" },
+ { "Insert ADD (16-bit Integer Add)\t+", "Insertar ADD (Suma Entero 16-bit)\t+" },
+ { "Insert SUB (16-bit Integer Subtract)\t-", "Insertar SUB (Resta Entero 16-bit)\t-" },
+ { "Insert MUL (16-bit Integer Multiply)\t*", "Insertar MUL (Multiplica Entero 16-bit)\t*" },
+ { "Insert DIV (16-bit Integer Divide)\tD", "Insertar DIV (Divide Entero 16-bit)\tD" },
+ { "Insert Shift Register", "Insertar Registro de Desplazamiento" },
+ { "Insert Look-Up Table", "Insertar Tabla de Busqueda" },
+ { "Insert Piecewise Linear", "Insertar Linealización por Segmentos" },
+ { "Insert Formatted String Over UART", "Insertar Cadena Formateada en la UART" },
+ { "Insert &UART Send", "Insertar &UART Enviar" },
+ { "Insert &UART Receive", "Insertar &UART Recibir" },
+ { "Insert Set PWM Output", "Insertar Valor Salida PWM" },
+ { "Insert A/D Converter Read\tP", "Insertar Lectura Conversor A/D\tP" },
+ { "Insert Make Persistent", "Insertar Hacer Permanente" },
+ { "Make Norm&al\tA", "Hacer Norm&al\tA" },
+ { "Make &Negated\tN", "Hacer &Negado\tN" },
+ { "Make &Set-Only\tS", "Hacer &Solo-Activar\tS" },
+ { "Make &Reset-Only\tR", "Hace&r Solo-Desactivar\tR" },
+ { "&MCU Parameters...", "&Parametros del Micro..." },
+ { "(no microcontroller)", "(no microcontrolador)" },
+ { "&Microcontroller", "&Microcontrolador" },
+ { "Si&mulation Mode\tCtrl+M", "Modo Si&mulación \tCtrl+M" },
+ { "Start &Real-Time Simulation\tCtrl+R", "Empezar Simulación en Tiempo &Real\tCtrl+R" },
+ { "&Halt Simulation\tCtrl+H", "Parar Simulación\tCtrl+H" },
+ { "Single &Cycle\tSpace", "Solo un &Ciclo\tSpace" },
+ { "&Compile\tF5", "&Compilar\tF5" },
+ { "Compile &As...", "Compilar &Como..." },
+ { "&Manual...\tF1", "&Manual...\tF1" },
+ { "&About...", "&Acerca de..." },
+ { "&File", "&Archivo" },
+ { "&Edit", "&Editar" },
+ { "&Settings", "&Configuraciones" },
+ { "&Instruction", "&Instrucción" },
+ { "Si&mulate", "Si&mular" },
+ { "&Compile", "&Compilar" },
+ { "&Help", "&Ayuda" },
+ { "no MCU selected", "micro no seleccionado" },
+ { "cycle time %.2f ms", "tiempo ciclo %.2f ms" },
+ { "processor clock %.4f MHz", "reloj procesador %.4f MHz" },
+ { "Internal error relating to PIC paging; make program smaller or reshuffle it.", "Error interno relativo a la paginación del PIC; Haz el programa mas pequeño o reorganizalo" },
+ { "PWM frequency too fast.", "Frecuencia del PWM demasiado alta." },
+ { "PWM frequency too slow.", "Frecuencia del PWM demasiado baja." },
+ { "Cycle time too fast; increase cycle time, or use faster crystal.", "Tiempo del Ciclo demasiado rapido; aumenta el tiempo de ciclo, o usa un cristal de mas Mhz." },
+ { "Cycle time too slow; decrease cycle time, or use slower crystal.", "Tiempo del Ciclo demasiado lento; incrementa el tiempo de ciclo, o usa un cristal de menos Mhz." },
+ { "Couldn't open file '%s'", "No puedo abrir el archivo '%s'" },
+ { "Zero baud rate not possible.", "Cero baudios no es posible." },
+ { "Compile successful; wrote IHEX for PIC16 to '%s'.\r\n\r\nConfiguration word (fuses) has been set for crystal oscillator, BOD enabled, LVP disabled, PWRT enabled, all code protection off.\r\n\r\nUsed %d/%d words of program flash (chip %d%% full).", "Compilación correcta; escrito IHEX para PIC16 en '%s'.\r\n\r\nBits de Configurarión (fuses) han sido establecidos para oscilador a cristal, BOD activado, LVP desactivado, PWRT activado, Todos los bits de protección desactivados.\r\n\r\nUsadas %d/%d palabras de programa en flash (Chip %d%% lleno)." },
+ { "Type", "Tipo" },
+ { "Timer", "Temporizador" },
+ { "Counter", "Contador" },
+ { "Reset", "Reiniciar" },
+ { "OK", "OK" },
+ { "Cancel", "Cancelar" },
+ { "Empty textbox; not permitted.", "Texto vacio; no permitido" },
+ { "Bad use of quotes: <%s>", "Mal uso de las comillas: <%s>" },
+ { "Turn-On Delay", "Activar Retardado" },
+ { "Turn-Off Delay", "Desactivar Retardado" },
+ { "Retentive Turn-On Delay", "Activar Retardado con Memoria" },
+ { "Delay (ms):", "Retardo (ms):" },
+ { "Delay too long; maximum is 2**31 us.", "Retardo demasiado largo; maximo 2**31 us." },
+ { "Delay cannot be zero or negative.", "El retardo no puede ser cero o negativo." },
+ { "Count Up", "Contador Creciente" },
+ { "Count Down", "Contador Decreciente" },
+ { "Circular Counter", "Contador Circular" },
+ { "Max value:", "Valor Max:" },
+ { "True if >= :", "Verdad si >= :" },
+ { "If Equals", "Si igual" },
+ { "If Not Equals", "Si NO igual" },
+ { "If Greater Than", "Si mayor que" },
+ { "If Greater Than or Equal To", "Si mayor o igual que" },
+ { "If Less Than", "Si menor que" },
+ { "If Less Than or Equal To", "Si menor o igual que" },
+ { "'Closed' if:", "'Cerrado' si:" },
+ { "Move", "Mover" },
+ { "Read A/D Converter", "Leer Conversor A/D" },
+ { "Duty cycle var:", "Var Ancho Ciclo:" },
+ { "Frequency (Hz):", "Frecuencia (Hz):" },
+ { "Set PWM Duty Cycle", "Poner Ancho de Pulso PWM" },
+ { "Source:", "Fuente:" },
+ { "Receive from UART", "Recibido en la UART" },
+ { "Send to UART", "Enviado a la UART" },
+ { "Add", "Sumar" },
+ { "Subtract", "Restar" },
+ { "Multiply", "Multiplicar" },
+ { "Divide", "Dividir" },
+ { "Destination:", "Destino:" },
+ { "is set := :", "esta puesto := :" },
+ { "Name:", "Nombre:" },
+ { "Stages:", "Fases:" },
+ { "Shift Register", "Registro Desplazamiento" },
+ { "Not a reasonable size for a shift register.", "No es un tamaño razonable para el Registro de Desplazamiento." },
+ { "String:", "Cadena:" },
+ { "Formatted String Over UART", "Cadena Formateada para UART" },
+ { "Variable:", "Variable:" },
+ { "Make Persistent", "Hacer permanente" },
+ { "Too many elements in subcircuit!", "Demasiados elementos en un SubCircuito!" },
+ { "Too many rungs!", "Demasiadas Lineas (rungs)!" },
+ { "Error", "Error" },
+ { "ANSI C target does not support peripherals (UART, PWM, ADC, EEPROM). Skipping that instruction.", "ANSI C de destino no soporta perifericos (UART, PWM, ADC, EEPROM). Evite esa instrucción." },
+ { "Compile successful; wrote C source code to '%s'.\r\n\r\nThis is not a complete C program. You have to provide the runtime and all the I/O routines. See the comments in the source code for information about how to do this.", "Compilación correcta: Escrito Código Fuente en C en '%s'.\r\n\r\nNo es un programa completo en C. Tiene que añadirle el procedimiento principal y todas las rutinas de E/S. Vea los comentarios en el código fuente para mas información sobre como hacer esto" },
+ { "Cannot delete rung; program must have at least one rung.", "No puedo borrar la Linea (rung); el programa debe tener al menos una Linea (rung)." },
+ { "Out of memory; simplify program or choose microcontroller with more memory.", "Fuera de Memoria; Simplifique el programa o elija un micro con mas memoria.." },
+ { "Must assign pins for all ADC inputs (name '%s').", "Debe asignar patas para todas las entradas del ADC (nombre '%s')." },
+ { "Internal limit exceeded (number of vars)", "Limite interno superado (numero de variables)" },
+ { "Internal relay '%s' never assigned; add its coil somewhere.", "No ha asignado el rele interno '%s'; añada la bobina en cualquier parte del programa." },
+ { "Must assign pins for all I/O.\r\n\r\n'%s' is not assigned.", "Debe asignar patas a todas las E/S.\r\n\r\n'%s' no esta asignada." },
+ { "UART in use; pins %d and %d reserved for that.", "UART en uso; patas %d y %d reservadas para eso." },
+ { "PWM in use; pin %d reserved for that.", "PWM en uso; pata %d reservada para eso." },
+ { "UART baud rate generator: divisor=%d actual=%.4f for %.2f%% error.\r\n\r\nThis is too large; try a different baud rate (slower probably), or a crystal frequency chosen to be divisible by many common baud rates (e.g. 3.6864 MHz, 14.7456 MHz).\r\n\r\nCode will be generated anyways but serial may be unreliable or completely broken.", "UART generador de baudios: divisor=%d actual=%.4f para %.2f%% error.\r\n\r\nEs demasiado grande; Prueba con otro valor de baudios (probablemente menor), o un cristal cuya frecuencia sea divible por los baudios mas comunes (p.e. 3.6864MHz, 14.7456MHz).\r\n\r\nEl código se genera de todas formas pero las tramas serie sean inestable o no entendible." },
+ { "UART baud rate generator: too slow, divisor overflows. Use a slower crystal or a faster baud rate.\r\n\r\nCode will be generated anyways but serial will likely be completely broken.", "UART generador de baudios: demasiado lento, divisor demasiado grande. Use un cristal mas lento o mayor baudios.\r\n\r\nEl código se genera de todas formas pero las tramas serie serán no entendible.." },
+ { "Couldn't open '%s'\n", "No puedo abrir '%s'\n" },
+ { "Timer period too short (needs faster cycle time).", "Periodo de Tiempo demasiado corto (se necesita un tiempo de ciclo menor)." },
+ { "Timer period too long (max 32767 times cycle time); use a slower cycle time.", "Periodo del temporizador demasiado largo (max. 32767 veces el tiempo de ciclo); use un tiempo de ciclo mayor." },
+ { "Constant %d out of range: -32768 to 32767 inclusive.", "Constante %d fuera de rango: -32768 a 32767 inclusive." },
+ { "Move instruction: '%s' not a valid destination.", "Instrucción Move: '%s' no es valido el destino." },
+ { "Math instruction: '%s' not a valid destination.", "Instrucción Math: '%s' no es valido el destino." },
+ { "Piecewise linear lookup table with zero elements!", "tabla de linealizacion por segmentos con cero elementos!" },
+ { "x values in piecewise linear table must be strictly increasing.", "Los valores X en la tabla de linealización por segmentos deben ser estrictamente incrementales." },
+ { "Numerical problem with piecewise linear lookup table. Either make the table entries smaller, or space the points together more closely.\r\n\r\nSee the help file for details.", "Problema numérico con la tabla de linealización por segmentos. Haz la tabla de entradas mas pequeña, o aleja mas los puntos juntos.\r\n\r\nMira la ayuda para mas detalles." },
+ { "Multiple escapes (\\0-9) present in format string, not allowed.", "No esta permitido mas de un caracter especial (\\0-9) dentro de la cadena de caractares." },
+ { "Bad escape: correct form is \\xAB.", "Caracter Especial Erroneo: la forma correcta es = \\xAB." },
+ { "Bad escape '\\%c'", "Caracter Especial Erroneo '\\%c'" },
+ { "Variable is interpolated into formatted string, but none is specified.", "Se ha declarado un parametro dentro la cadena de caracteres, pero falta especificar la variable." },
+ { "No variable is interpolated into formatted string, but a variable name is specified. Include a string like '\\-3', or leave variable name blank.", "No se ha declarado un parametro dentro de la cadena de caractares pero sin embargo se ha especificado una variable. Añada un cadena como '\\-3', o quite el nombre de la variable." },
+ { "Empty row; delete it or add instructions before compiling.", "Fila vacia; borrela o añada instrucciones antes de compilar." },
+ { "Couldn't write to '%s'", "No puedo escribir en '%s'." },
+ { "Unsupported op (anything ADC, PWM, UART, EEPROM) for interpretable target.", "Op no soportada en el interprete (algun ADC, PWM, UART, EEPROM)." },
+ { "Compile successful; wrote interpretable code to '%s'.\r\n\r\nYou probably have to adapt the interpreter to your application. See the documentation.", "Compilación correcta: Código para interprete escrito en '%s'.\r\n\r\nProblablemente tengas que adaptar el interprete a tu aplicación. Mira la documentación." },
+ { "Microcontroller '%s' not supported.\r\n\r\nDefaulting to no selected MCU.", "Microcontrolador '%s' no sorportado.\r\n\r\nForzando ninguna CPU." },
+ { "File format error; perhaps this program is for a newer version of LDmicro?", "Error en el formato de archivo; quizas este programa es una version mas moderna de LDmicro?." },
+ { "Index:", "Indice:" },
+ { "Points:", "Puntos:" },
+ { "Count:", "Cantidad:" },
+ { "Edit table of ASCII values like a string", "Editar tabla de valores ascii como una cadena" },
+ { "Look-Up Table", "Buscar en Tabla" },
+ { "Piecewise Linear Table", "Tabla de linealización por segmentos" },
+ { "LDmicro Error", "LDmicro Error" },
+ { "Compile Successful", "Compilación Correcta" },
+ { "digital in", "entrada digital" },
+ { "digital out", "salida digital" },
+ { "int. relay", "rele interno" },
+ { "UART tx", "UART tx" },
+ { "UART rx", "UART rx" },
+ { "PWM out", "salida PWM" },
+ { "turn-on delay", "activar retardo" },
+ { "turn-off delay", "desactivar retardo" },
+ { "retentive timer", "temporizador con memoria" },
+ { "counter", "contador" },
+ { "general var", "var general" },
+ { "adc input", "entrada adc" },
+ { "<corrupt!>", "<estropeado!>" },
+ { "(not assigned)", "(no asignado)" },
+ { "<no UART!>", "<no UART!>" },
+ { "<no PWM!>", "<no PWM!>" },
+ { "TOF: variable cannot be used elsewhere", "TOF: la variable no puede ser usada en otra parte" },
+ { "TON: variable cannot be used elsewhere", "TON: la variable no puede ser usada en otra parte" },
+ { "RTO: variable can only be used for RES elsewhere", "RTO: la variable solo puede ser usada como RES en otra parte" },
+ { "Variable '%s' not assigned to, e.g. with a MOV statement, an ADD statement, etc.\r\n\r\nThis is probably a programming error; now it will always be zero.", "Variable '%s' no asignada, p.e. con el comando MOV, una instrucción ADD, etc.\r\n\r\nEsto es probablemente un error de programación; valdrá cero." },
+ { "Variable for '%s' incorrectly assigned: %s.", "Variable para '%s' incorrectamente asignada: %s." },
+ { "Division by zero; halting simulation", "División por cero; Parando simulación" },
+ { "!!!too long!!!", "!!Muy grande!!" },
+ { "\n\nI/O ASSIGNMENT:\n\n", "\n\nE/S ASIGNACIÓN:\n\n" },
+ { " Name | Type | Pin\n", " Nombre | Tipo | Pata\n" },
+ { "Serial (UART) will use pins %d and %d.\r\n\r\n", "El Puerto Serie (UART) usará los pines %d y %d.\r\n\r\n" },
+};
+static Lang LangEs = {
+ LangEsTable, sizeof(LangEsTable)/sizeof(LangEsTable[0])
+};
+#endif
+#ifdef LDLANG_FR
+static LangTable LangFrTable[] = {
+ { "Target frequency %d Hz, closest achievable is %d Hz (warning, >5%% error).", "Fréquence de la cible %d Hz, fonction accomplie à %d Hz (ATTENTION, >5% erreur)." },
+ { "Compile successful; wrote IHEX for AVR to '%s'.\r\n\r\nRemember to set the processor configuration (fuses) correctly. This does not happen automatically.", "Compilé avec succès. Ecriture du fichier IHEX pour AVR sous '%s'.\r\n\r\nVous devez configurer manuellement les Bits de configuration (fusibles). Ceci n'est pas accompli automatiquement." },
+ { "( ) Normal", "( ) Normal" },
+ { "(/) Negated", "(/) Inversée" },
+ { "(S) Set-Only", "(S) Activer" },
+ { "(R) Reset-Only", "(R) RAZ" },
+ { "Pin on MCU", "Broche MCU" },
+ { "Coil", "Bobine" },
+ { "Comment", "Commentaire" },
+ { "Cycle Time (ms):", "Temps de cycle (ms):" },
+ { "Crystal Frequency (MHz):", "Fréquence quartz (MHz):" },
+ { "UART Baud Rate (bps):", "UART Vitesse (bps):" },
+ { "Serial (UART) will use pins %d and %d.\r\n\r\n", "Communication série utilisera broches %d et %d.\r\n\r\n" },
+ { "Please select a micro with a UART.\r\n\r\n", "Sélectionnez un processeur avec UART.\r\n\r\n" },
+ { "No serial instructions (UART Send/UART Receive) are in use; add one to program before setting baud rate.\r\n\r\n", "Aucune instruction (émission ou réception UART) n'est utilisée; ajouter une instruction avant de fixer les vitesses.\r\n\r\n" },
+ { "The cycle time for the 'PLC' runtime generated by LDmicro is user-configurable. Very short cycle times may not be achievable due to processor speed constraints, and very long cycle times may not be achievable due to hardware overflows. Cycle times between 10 ms and 100 ms will usually be practical.\r\n\r\nThe compiler must know what speed crystal you are using with the micro to convert between timing in clock cycles and timing in seconds. A 4 MHz to 20 MHz crystal is typical; check the speed grade of the part you are using to determine the maximum allowable clock speed before choosing a crystal.", "Le temps de cycle de l'API (automate programmable) est configurable par l'utilisateur. Un temps trop court n'est pas utilisable dû à des contraintes de vitesse du processeur. Des temps de cycle trop longs ne sont pas utilisables à cause du dépassement de capacité des registres. Des temps de cycle compris entre 10 ms et 100 ms sont géneralement utilisables.\r\n\r\nLe compilateur doit connaitre la fréquence du quartz utilisé pour définir les temps de cycles d'horloge ainsi que les temporisations, les fréquences de 4 à 20 mhz sont typiques. Déterminer la vitesse désirée avant de choisir le quartz." },
+ { "PLC Configuration", "Configuration API" },
+ { "Zero cycle time not valid; resetting to 10 ms.", "Temps de cycle non valide ; remis à 10 ms." },
+ { "Source", "Source" },
+ { "Internal Relay", "Relais interne" },
+ { "Input pin", "Entrée" },
+ { "Output pin", "Sortie" },
+ { "|/| Negated", "|/| Normalement fermé" },
+ { "Contacts", "Contacts" },
+ { "No ADC or ADC not supported for selected micro.", "Pas de convertisseur A/D ou convertisseur non supporté pour le MCU sélectionné." },
+ { "Assign:", "Affectations:" },
+ { "No microcontroller has been selected. You must select a microcontroller before you can assign I/O pins.\r\n\r\nSelect a microcontroller under the Settings menu and try again.", "Aucun microcontrolleur sélectionné. Vous devez sélectionner un microcontroleur avant de définir l'utilisation des broches.\r\n\r\nSélectionnez un micro dans le menu et essayez à nouveau." },
+ { "I/O Pin Assignment", "Affectation broches E/S" },
+ { "Can't specify I/O assignment for ANSI C target; compile and see comments in generated source code.", "Ne pas spécifier les E/S pour code en ANSI C; Compiler et voir les commentaires dans le code source généré." },
+ { "Can't specify I/O assignment for interpretable target; see comments in reference implementation of interpreter.", "Ne pas spécifier les E/S pour sortie en code interprété; Voir les commentaires pour l'implémentation de l'interpréteur ." },
+ { "Can only assign pin number to input/output pins (Xname or Yname or Aname).", "Vous pouvez uniquement affecter les broches Entrées/Sorties (XName , YName ou AName)." },
+ { "No ADC or ADC not supported for this micro.", "Pas de convertisseur A/D ou convertisseur non supporté pour ce micro." },
+ { "Rename I/O from default name ('%s') before assigning MCU pin.", "Changer les noms par défauts des E/S ('%s') avant de leur affecter une broche MCU." },
+ { "I/O Pin", "Broches E/S" },
+ { "(no pin)", "(Aucune broche)" },
+ { "<UART needs!>", "<UART nécessaire!>" },
+ { "<PWM needs!>", "<PWM nécessaire!>" },
+ { "<not an I/O!>", "<Pas une E/S!>" },
+ { "Export As Text", "Exporter en texte" },
+ { "Couldn't write to '%s'.", "Impossible d'écrire '%s'." },
+ { "Compile To", "Compiler sous" },
+ { "Must choose a target microcontroller before compiling.", "Choisir un microcontrolleur avant de compiler." },
+ { "UART function used but not supported for this micro.", "Des fonctions UART sont utilisées, mais non supportées par ce micro." },
+ { "PWM function used but not supported for this micro.", "Fonctions PWM utilisées mais non supportées par ce micro." },
+ { "The program has changed since it was last saved.\r\n\r\nDo you want to save the changes?", "Le programme a changé depuis la dernière sauvegarde.\r\n\r\nVoulez-vous sauvegarder les changements?" },
+ { "--add comment here--", "--Ajouter les commentaires ICI--" },
+ { "Start new program?", "Commencer un nouveau programme?" },
+ { "Couldn't open '%s'.", "Impossible d'ouvrir '%s'." },
+ { "Name", "Nom" },
+ { "State", "Etat" },
+ { "Pin on Processor", "Broche du Micro" },
+ { "MCU Port", "Port du processeur" },
+ { "LDmicro - Simulation (Running)", "LDmicro - Simulation (en cours)" },
+ { "LDmicro - Simulation (Stopped)", "LDmicro - Simulation (Arrétée)" },
+ { "LDmicro - Program Editor", "LDmicro – Edition du programme " },
+ { " - (not yet saved)", " - (fichier non sauvegardé)" },
+ { "&New\tCtrl+N", "&Nouveau\tCtrl+N" },
+ { "&Open...\tCtrl+O", "&Ouvrir...\tCtrl+O" },
+ { "&Save\tCtrl+S", "&Sauvegarder\tCtrl+S" },
+ { "Save &As...", "S&auvegarder sous..." },
+ { "&Export As Text...\tCtrl+E", "&Exporter en texte...\tCtrl+E" },
+ { "E&xit", "Quitter" },
+ { "&Undo\tCtrl+Z", "Annuler\tCtrl+Z" },
+ { "&Redo\tCtrl+Y", "&Refaire\tCtrl+Y" },
+ { "Insert Rung &Before\tShift+6", "Insérer ligne avant\tShift+6" },
+ { "Insert Rung &After\tShift+V", "Insérer ligne &après\tShift+V" },
+ { "Move Selected Rung &Up\tShift+Up", "Déplacer la ligne sélectionnée au dessus\tShift+Up" },
+ { "Move Selected Rung &Down\tShift+Down", "Déplacer la ligne sélectionnée au dessous\tShift+Down" },
+ { "&Delete Selected Element\tDel", "&Effacer l'élement sélectionné\tSuppr" },
+ { "D&elete Rung\tShift+Del", "Supprimer la ligne\tShift+Suppr" },
+ { "Insert Co&mment\t;", "Insérer commentaire\t;" },
+ { "Insert &Contacts\tC", "Insérer &contact\tC" },
+ { "Insert OSR (One Shot Rising)\t&/", "Insérer OSR (Front montant)\t&/" },
+ { "Insert OSF (One Shot Falling)\t&\\", "Insérer OSF (Front descendant)\t&\\" },
+ { "Insert T&ON (Delayed Turn On)\tO", "Insérer T&ON (Tempo travail)\tO" },
+ { "Insert TO&F (Delayed Turn Off)\tF", "Insérer TO&F (Tempo repos)\tF" },
+ { "Insert R&TO (Retentive Delayed Turn On)\tT", "Insérer R&TO (Tempo totalisatrice)\tT" },
+ { "Insert CT&U (Count Up)\tU", "Insérer CT&U (Compteur)\tU" },
+ { "Insert CT&D (Count Down)\tI", "Insérer CT&D (Décompteur)\tI" },
+ { "Insert CT&C (Count Circular)\tJ", "Insérer CT&C (Compteur cyclique)\tJ" },
+ { "Insert EQU (Compare for Equals)\t=", "Insérer EQU (Compare pour égalité)\t=" },
+ { "Insert NEQ (Compare for Not Equals)", "Insérer NEQ (Compare pour inégalité)" },
+ { "Insert GRT (Compare for Greater Than)\t>", "Insérer GRT (Compare plus grand que)\t>" },
+ { "Insert GEQ (Compare for Greater Than or Equal)\t.", "Insérer GEQ (Compare plus grand ou égal à)\t." },
+ { "Insert LES (Compare for Less Than)\t<", "Insérer LES (Compare plus petit que)\t<" },
+ { "Insert LEQ (Compare for Less Than or Equal)\t,", "Insérer LEQ (Compare plus petit ou égal à)\t," },
+ { "Insert Open-Circuit", "Insérer circuit ouvert" },
+ { "Insert Short-Circuit", "Insérer court circuit" },
+ { "Insert Master Control Relay", "Insérer relais de contrôle maitre" },
+ { "Insert Coi&l\tL", "Insérer bobine re&lais \tL" },
+ { "Insert R&ES (Counter/RTO Reset)\tE", "Insérer R&ES (Remise à zéro RTO/compteur)\tE" },
+ { "Insert MOV (Move)\tM", "Insérer MOV (Mouvoir)\tM" },
+ { "Insert ADD (16-bit Integer Add)\t+", "Insérer ADD (Addition entier 16-bit)\t+" },
+ { "Insert SUB (16-bit Integer Subtract)\t-", "Insérer SUB (Soustraction entier 16-bit)\t-" },
+ { "Insert MUL (16-bit Integer Multiply)\t*", "Insérer MUL (Multiplication entier 16-bit)\t*" },
+ { "Insert DIV (16-bit Integer Divide)\tD", "Insérer DIV (Division entier 16-bit)\tD" },
+ { "Insert Shift Register", "Insérer registre à décalage" },
+ { "Insert Look-Up Table", "Insérer tableau indexé" },
+ { "Insert Piecewise Linear", "Insérer tableau d'éléments linéaires" },
+ { "Insert Formatted String Over UART", "Insérer chaine formattée pour l'UART" },
+ { "Insert &UART Send", "Insérer émission &UART" },
+ { "Insert &UART Receive", "Insérer réception &UART" },
+ { "Insert Set PWM Output", "Insérer fixer sortie PWM" },
+ { "Insert A/D Converter Read\tP", "Insérer lecture convertisseur A/D\tP" },
+ { "Insert Make Persistent", "Insérer mettre rémanent" },
+ { "Make Norm&al\tA", "Mettre norm&al\tA" },
+ { "Make &Negated\tN", "I&nverser\tN" },
+ { "Make &Set-Only\tS", "Activer uniquement\tS" },
+ { "Make &Reset-Only\tR", "Faire RAZ uniquement\tR" },
+ { "&MCU Parameters...", "&Paramètres MCU..." },
+ { "(no microcontroller)", "(pas de microcontrolleur)" },
+ { "&Microcontroller", "&Microcontrolleur" },
+ { "Si&mulation Mode\tCtrl+M", "Mode si&mulation\tCtrl+M" },
+ { "Start &Real-Time Simulation\tCtrl+R", "Commencer la simulation en temps &réel\tCtrl+R" },
+ { "&Halt Simulation\tCtrl+H", "&Arrêter la simulation\tCtrl+H" },
+ { "Single &Cycle\tSpace", "&Cycle unique\tEspace" },
+ { "&Compile\tF5", "&Compiler\tF5" },
+ { "Compile &As...", "Compiler sous..." },
+ { "&Manual...\tF1", "&Manuel...\tF1" },
+ { "&About...", "&A propos..." },
+ { "&File", "&Fichier" },
+ { "&Edit", "&Edition" },
+ { "&Settings", "&Paramètres" },
+ { "&Instruction", "&Instruction" },
+ { "Si&mulate", "Si&mulation" },
+ { "&Compile", "&Compilation" },
+ { "&Help", "&Aide" },
+ { "no MCU selected", "pas de MCU sélectionné" },
+ { "cycle time %.2f ms", "cycle %.2f ms" },
+ { "processor clock %.4f MHz", "horloge processeur %.4f MHz" },
+ { "Internal error relating to PIC paging; make program smaller or reshuffle it.", "Erreur interne dans l'utilisation des pages du PIC; Diminuer le programme ou le remanier" },
+ { "PWM frequency too fast.", "Fréquence PWM trop rapide." },
+ { "PWM frequency too slow.", "Frequence PWM trop lente." },
+ { "Cycle time too fast; increase cycle time, or use faster crystal.", "Temps cycle trop court; augmenter le temps de cycle ou utiliser un quartz plus rapide." },
+ { "Cycle time too slow; decrease cycle time, or use slower crystal.", "Temps de cycle trop long ; Diminuer le temps de cycle ou la fréquence du quartz ." },
+ { "Couldn't open file '%s'", "Impossible d'ouvrir le fichier '%s'" },
+ { "Zero baud rate not possible.", "Vitesse transmission = 0 : impossible" },
+ { "Compile successful; wrote IHEX for PIC16 to '%s'.\r\n\r\nConfiguration word (fuses) has been set for crystal oscillator, BOD enabled, LVP disabled, PWRT enabled, all code protection off.\r\n\r\nUsed %d/%d words of program flash (chip %d%% full).", "Compilé avec succès; Ecriture IHEX pour PIC16 sous '%s'.\r\n\r\nLes bits de configuration (fuse) : Oscillateur quartz, BOD activé, LVP déactivé, PWRT activé, sans code de protection.\r\n\r\nUtilise %d/%d mots du programme flash (Chip %d%% au total)." },
+ { "Type", "Type" },
+ { "Timer", "Temporisation" },
+ { "Counter", "Compteur" },
+ { "Reset", "RAZ" },
+ { "OK", "OK" },
+ { "Cancel", "Annuler" },
+ { "Empty textbox; not permitted.", "Zone de texte vide; interdite" },
+ { "Bad use of quotes: <%s>", "Utilisation incorrecte des guillemets: <%s>" },
+ { "Turn-On Delay", "Tempo travail" },
+ { "Turn-Off Delay", "Tempo repos" },
+ { "Retentive Turn-On Delay", "Temporisation totalisatrice" },
+ { "Delay (ms):", "Temps (ms):" },
+ { "Delay too long; maximum is 2**31 us.", "Temps trop long; maximum 2**31 us." },
+ { "Delay cannot be zero or negative.", "Tempo ne peut être à ZERO ou NEGATIF." },
+ { "Count Up", "Compteur" },
+ { "Count Down", "Décompteur" },
+ { "Circular Counter", "Compteur cyclique" },
+ { "Max value:", "Valeur max.:" },
+ { "True if >= :", "Vrai si >= :" },
+ { "If Equals", "Si EGAL" },
+ { "If Not Equals", "Si non EGAL à" },
+ { "If Greater Than", "Si plus grand que" },
+ { "If Greater Than or Equal To", "Si plus grand ou égal à" },
+ { "If Less Than", "Si plus petit que" },
+ { "If Less Than or Equal To", "Si plus petit ou égal à" },
+ { "'Closed' if:", "'Fermé' si:" },
+ { "Move", "Mouvoir" },
+ { "Read A/D Converter", "Lecture du convertisseur A/D" },
+ { "Duty cycle var:", "Utilisation:" },
+ { "Frequency (Hz):", "Frequence (Hz):" },
+ { "Set PWM Duty Cycle", "Fixer le rapport de cycle PWM" },
+ { "Source:", "Source:" },
+ { "Receive from UART", "Reception depuis l'UART" },
+ { "Send to UART", "Envoyer vers l'UART" },
+ { "Add", "Addition" },
+ { "Subtract", "Soustraction" },
+ { "Multiply", "Multiplication" },
+ { "Divide", "Division" },
+ { "Destination:", "Destination:" },
+ { "is set := :", "Valeur := :" },
+ { "Name:", "Nom:" },
+ { "Stages:", "Etapes:" },
+ { "Shift Register", "Registre à décalage" },
+ { "Not a reasonable size for a shift register.", "N'est pas une bonne taille pour un registre à décalage." },
+ { "String:", "Chaine:" },
+ { "Formatted String Over UART", "Chaine formatée pour l'UART" },
+ { "Variable:", "Variable:" },
+ { "Make Persistent", "Mettre rémanent" },
+ { "Too many elements in subcircuit!", "Trop d'éléments dans le circuit secondaire !" },
+ { "Too many rungs!", "Trop de séquences!" },
+ { "Error", "Erreur" },
+ { "ANSI C target does not support peripherals (UART, PWM, ADC, EEPROM). Skipping that instruction.", "La sortie en code ANSI C ne supporte pas les périphériques (UART, ADC, EEPROM). Ne pas utiliser ces instructions." },
+ { "Compile successful; wrote C source code to '%s'.\r\n\r\nThis is not a complete C program. You have to provide the runtime and all the I/O routines. See the comments in the source code for information about how to do this.", "Compilé avec succès; Le code source C enregistré sous '%s'.\r\n\r\nCe programme n'est pas complet. Vous devez prévoir le runtime ainsi que toutes les routines d'entrées/sorties. Voir les commentaires pour connaitre la façon de procéder." },
+ { "Cannot delete rung; program must have at least one rung.", "Impossible de supprimer la ligne, le programme doit avoir au moins une ligne." },
+ { "Out of memory; simplify program or choose microcontroller with more memory.", "Mémoire insuffisante; simplifiez le programme ou utiliser un controleur avec plus de mémoire." },
+ { "Must assign pins for all ADC inputs (name '%s').", "Vous devez spécifier une broche pour toutes les entrées ADC (nom '%s')." },
+ { "Internal limit exceeded (number of vars)", "Vous dépassez la limite interne du nombre de variables" },
+ { "Internal relay '%s' never assigned; add its coil somewhere.", "Relais internes '%s', jamais utilisés, à utiliser pour la commande de bobines dans le programme." },
+ { "Must assign pins for all I/O.\r\n\r\n'%s' is not assigned.", "Vous devez spécifier les broches pour toutes les E/S.\r\n\r\n'%s' ." },
+ { "UART in use; pins %d and %d reserved for that.", "UART utilisé; broches %d et %d réservée pour cette fonction." },
+ { "PWM in use; pin %d reserved for that.", "PWM utilisé; broche %d réservée pour cela." },
+ { "UART baud rate generator: divisor=%d actual=%.4f for %.2f%% error.\r\n\r\nThis is too large; try a different baud rate (slower probably), or a crystal frequency chosen to be divisible by many common baud rates (e.g. 3.6864 MHz, 14.7456 MHz).\r\n\r\nCode will be generated anyways but serial may be unreliable or completely broken.", "UART Générateur vitesse: Diviseur=%d actuel=%.4f pour %.2f%% Erreur.\r\n\r\nCeci est trop important; Essayez une autre vitesse (probablement plus lente), ou choisir un quartz divisible par plus de vitesses de transmission (comme 3.6864MHz, 14.7456MHz).\r\n\r\nCode est tout de même généré, mais la liaison peut être inutilisable ou la transmission erronée." },
+ { "UART baud rate generator: too slow, divisor overflows. Use a slower crystal or a faster baud rate.\r\n\r\nCode will be generated anyways but serial will likely be completely broken.", "Générateur vitesse UART trop lent, dépassement de capacité du diviseur. Utiliser un quartz plus lent ou une vitesse plus élevée.\r\n\r\nCode est généré mais la liaison semble inutilisable." },
+ { "Couldn't open '%s'\n", "Impossible d'ouvrir '%s'\n" },
+ { "Timer period too short (needs faster cycle time).", "Période temporisation trop courte (Diminuer le temps de cycle)." },
+ { "Timer period too long (max 32767 times cycle time); use a slower cycle time.", "Période de tempo trop longue (max. 32767 fois le temps de cycle); utiliser un temps de cycle plus long." },
+ { "Constant %d out of range: -32768 to 32767 inclusive.", "Constante %d hors limites: -32768 à 32767 inclus." },
+ { "Move instruction: '%s' not a valid destination.", "Instruction 'Mouvoir': '%s' n'est pas une destination valide." },
+ { "Math instruction: '%s' not a valid destination.", "Instruction Math: '%s' n'est pas une destination valide." },
+ { "Piecewise linear lookup table with zero elements!", "Le tableau indexé linéaire ne comporte aucun élément!" },
+ { "x values in piecewise linear table must be strictly increasing.", "Les valeurs x du tableau indexé linéaire doivent être obligatoirement dans un ordre croissant." },
+ { "Numerical problem with piecewise linear lookup table. Either make the table entries smaller, or space the points together more closely.\r\n\r\nSee the help file for details.", "Problème numérique avec le tableau. Commencer par les faibles valeurs ou rapprocher les points du tableau .\r\n\r\nVoir fichier d'aide pour plus de détails." },
+ { "Multiple escapes (\\0-9) present in format string, not allowed.", "Multiples ESC (\\0-9)présents dans un format chaines non permit." },
+ { "Bad escape: correct form is \\xAB.", "ESC incorrect: Forme correcte = \\xAB." },
+ { "Bad escape '\\%c'", "ESC incorrect '\\%c'" },
+ { "Variable is interpolated into formatted string, but none is specified.", "Une variable est appellée dans une chaine formattée, mais n'est pas spécifiée." },
+ { "No variable is interpolated into formatted string, but a variable name is specified. Include a string like '\\-3', or leave variable name blank.", "Aucune variable n'est appelée dans une chaine formattée, mais un nom de variable est spécifié . Insérer une chaine comme: '\\-3', ou laisser le nom de variable vide." },
+ { "Empty row; delete it or add instructions before compiling.", "Ligne vide; la supprimer ou ajouter instructions avant compilation." },
+ { "Couldn't write to '%s'", "Impossible d'écrire sous '%s'." },
+ { "Unsupported op (anything ADC, PWM, UART, EEPROM) for interpretable target.", "Instructions non supportées (comme ADC, PWM, UART, EEPROM ) pour sortie en code interprété." },
+ { "Compile successful; wrote interpretable code to '%s'.\r\n\r\nYou probably have to adapt the interpreter to your application. See the documentation.", "Compilé avec succès; Code interprété écrit sous '%s'.\r\n\r\nQue vous devez adapter probablement pour votre application. Voir documentation." },
+ { "Microcontroller '%s' not supported.\r\n\r\nDefaulting to no selected MCU.", "Microcontrolleur '%s' non supporté.\r\n\r\nErreur pas de MCU sélectionné." },
+ { "File format error; perhaps this program is for a newer version of LDmicro?", "Erreur format du fichier; ce programme est pour une nouvelle version de LDmicro." },
+ { "Index:", "Index:" },
+ { "Points:", "Points:" },
+ { "Count:", "Compteur:" },
+ { "Edit table of ASCII values like a string", "Editer tableau de valeur ASCII comme chaine" },
+ { "Look-Up Table", "Tableau indexé" },
+ { "Piecewise Linear Table", "Tableau d'éléments linéaire" },
+ { "LDmicro Error", "Erreur LDmicro" },
+ { "Compile Successful", "Compilé avec succès" },
+ { "digital in", "Entrée digitale" },
+ { "digital out", "Sortie digitale" },
+ { "int. relay", "Relais interne" },
+ { "UART tx", "UART tx" },
+ { "UART rx", "UART rx" },
+ { "PWM out", "Sortie PWM" },
+ { "turn-on delay", "Tempo travail" },
+ { "turn-off delay", "Tempo repos" },
+ { "retentive timer", "Tempo totalisatrice" },
+ { "counter", "Compteur" },
+ { "general var", "Var. générale" },
+ { "adc input", "Entrée ADC" },
+ { "<corrupt!>", "<Corrompu!>" },
+ { "(not assigned)", "(Non affecté)" },
+ { "<no UART!>", "<Pas UART!>" },
+ { "<no PWM!>", "<Pas de PWM!>" },
+ { "TOF: variable cannot be used elsewhere", "TOF: Variable ne peut être utilisée nullepart ailleurs" },
+ { "TON: variable cannot be used elsewhere", "TON: Variable ne peut être utilisée nullepart ailleurs" },
+ { "RTO: variable can only be used for RES elsewhere", "RTO: Variable ne peut être uniquement utilisée que pour RAZ" },
+ { "Variable '%s' not assigned to, e.g. with a MOV statement, an ADD statement, etc.\r\n\r\nThis is probably a programming error; now it will always be zero.", "Variable '%s' non affectée, ex: avec une commande MOV, une instruction ADD-etc.\r\n\r\nCeci est probablement une erreur de programmation; elle reste toujours à zéro." },
+ { "Variable for '%s' incorrectly assigned: %s.", "Variable pour '%s' Affectation incorrecte: %s." },
+ { "Division by zero; halting simulation", "Division par zéro; Simulation arrétée" },
+ { "!!!too long!!!", "!!!trop long!!" },
+ { "\n\nI/O ASSIGNMENT:\n\n", "\n\nE/S AFFECTATIONS:\n\n" },
+ { " Name | Type | Pin\n", " Nom | Type | Broche\n" },
+};
+static Lang LangFr = {
+ LangFrTable, sizeof(LangFrTable)/sizeof(LangFrTable[0])
+};
+#endif
+#ifdef LDLANG_IT
+static LangTable LangItTable[] = {
+ { "Target frequency %d Hz, closest achievable is %d Hz (warning, >5%% error).", "Target frequenza %d Hz, il più vicino realizzabile è %d Hz (avvertimento, >5%% di errore)." },
+ { "Compile successful; wrote IHEX for AVR to '%s'.\r\n\r\nRemember to set the processor configuration (fuses) correctly. This does not happen automatically.", "Compilazione ok; scritto IHEX per AVR a '%s'.\r\n\r\nRicorda di impostare il processore (Configurazione fusibili) correttamente. Questo non avviene automaticamente." },
+ { "( ) Normal", "( ) Aperto" },
+ { "(/) Negated", "(/) Negato" },
+ { "(S) Set-Only", "(S) Setta" },
+ { "(R) Reset-Only", "(R) Resetta" },
+ { "Pin on MCU", "Pin MCU" },
+ { "Coil", "Bobina" },
+ { "Comment", "Commento" },
+ { "Cycle Time (ms):", "Tempo di ciclo (ms):" },
+ { "Crystal Frequency (MHz):", "Frequenza quarzo (MHz):" },
+ { "UART Baud Rate (bps):", "UART Baud Rate (bps):" },
+ { "Serial (UART) will use pins %d and %d.\r\n\r\n", "Comunicazione seriale pin utilizzati %d et %d.\r\n\r\n" },
+ { "Please select a micro with a UART.\r\n\r\n", "Selezionare un processore dotato di UART.\r\n\r\n" },
+ { "No serial instructions (UART Send/UART Receive) are in use; add one to program before setting baud rate.\r\n\r\n", "Nessuna istruzione (UART trasmetti o UART ricevi) è utilizzata; aggiungere un istruzione prima di settare il baud rate.\r\n\r\n" },
+ { "The cycle time for the 'PLC' runtime generated by LDmicro is user-configurable. Very short cycle times may not be achievable due to processor speed constraints, and very long cycle times may not be achievable due to hardware overflows. Cycle times between 10 ms and 100 ms will usually be practical.\r\n\r\nThe compiler must know what speed crystal you are using with the micro to convert between timing in clock cycles and timing in seconds. A 4 MHz to 20 MHz crystal is typical; check the speed grade of the part you are using to determine the maximum allowable clock speed before choosing a crystal.", "Il tempo di ciclo per il 'PLC' LDmicro è configurabile dall' utente. Tempi di ciclo molto brevi possono non essere realizzabili a causa di vincoli di velocità del processore, e tempi di ciclo molto lunghi possono essere causa di overflow. Tempi di ciclo tra i 10 ms e di 100 ms di solito sono usuali.\r\n\r\nIl compilatore deve sapere che velocità di cristallo stai usando con il micro per convertire in cicli di clock i Tempi. Da 4 MHz a 20 MHz, è il cristallo tipico; determinare la velocità massima consentita prima di scegliere un cristallo." },
+ { "PLC Configuration", "Configurazione PLC" },
+ { "Zero cycle time not valid; resetting to 10 ms.", "Tempo di ciclo non valido; reimpostare a 10 ms." },
+ { "Source", "Sorgente" },
+ { "Internal Relay", "Relè interno" },
+ { "Input pin", "Input pin" },
+ { "Output pin", "Output pin" },
+ { "|/| Negated", "|/| Normalmente chiuso" },
+ { "Contacts", "Contatto" },
+ { "No ADC or ADC not supported for selected micro.", "Questo micro non suppota l'ADC." },
+ { "Assign:", "Assegna:" },
+ { "No microcontroller has been selected. You must select a microcontroller before you can assign I/O pins.\r\n\r\nSelect a microcontroller under the Settings menu and try again.", "Microcontrollore non selezionato. Selezionare un microcontrollore prima di assegnare i pin.\r\n\r\nSeleziona un microcontrollore dal il menu Impostazioni e riprova." },
+ { "I/O Pin Assignment", "Assegnazione Pin I/O" },
+ { "Can't specify I/O assignment for ANSI C target; compile and see comments in generated source code.", "Non specificare l'assegnazione dell' I/O per la generazione di ANSI C; compilare e visualizzare i commenti nel codice sorgente." },
+ { "Can't specify I/O assignment for interpretable target; see comments in reference implementation of interpreter.", "Non specificare l'assegnazione dell' I/O per la generazione di codice interpretabile; compilare e visualizzare i commenti nel codice sorgente." },
+ { "Can only assign pin number to input/output pins (Xname or Yname or Aname).", "Assegnare unicamente il numero di pin input/output (XNome, YNome ou ANome)." },
+ { "No ADC or ADC not supported for this micro.", "Questo micro non contiene ADC." },
+ { "Rename I/O from default name ('%s') before assigning MCU pin.", "Rinominare l' I/O per ottenere il nome di defolt ('%s') prima di assegnare i pin del Micro." },
+ { "I/O Pin", "I/O Pin" },
+ { "(no pin)", "(senza pin)" },
+ { "<UART needs!>", "<UART necessario!>" },
+ { "<PWM needs!>", "<PWM necessario!>" },
+ { "<not an I/O!>", "<nessun I/O!>" },
+ { "Export As Text", "Esportare il testo" },
+ { "Couldn't write to '%s'.", "Scrittura Impossibile '%s'." },
+ { "Compile To", "Per compilare" },
+ { "Must choose a target microcontroller before compiling.", "Scegliere un microcontrollore prima di compilare." },
+ { "UART function used but not supported for this micro.", "Le funzioni UART sono usate ma non supportate da questo micro." },
+ { "PWM function used but not supported for this micro.", "Le funzioni PWM sono usate ma non supportate da questo micro." },
+ { "The program has changed since it was last saved.\r\n\r\nDo you want to save the changes?", "Il programma è cambiato da quando è stato salvato l'ultima volta.\r\n\r\nDo si desidera salvare le modifiche? " },
+ { "--add comment here--", "--aggiungere il commento--" },
+ { "Start new program?", "Iniziare nuovo programma?" },
+ { "Couldn't open '%s'.", "Impossibile aprire '%s'." },
+ { "Name", "Nome" },
+ { "State", "Stato" },
+ { "Pin on Processor", "Pin del Micro" },
+ { "MCU Port", "Porta del processore" },
+ { "LDmicro - Simulation (Running)", "LDmicro - Simulazione (in corso)" },
+ { "LDmicro - Simulation (Stopped)", "LDmicro - Simulazione (Ferma)" },
+ { "LDmicro - Program Editor", "LDmicro - Scrivere il programma" },
+ { " - (not yet saved)", " - (non ancora salvato)" },
+ { "&New\tCtrl+N", "&Nuovo\tCtrl+N" },
+ { "&Open...\tCtrl+O", "&Aprire...\tCtrl+O" },
+ { "&Save\tCtrl+S", "&Salva\tCtrl+S" },
+ { "Save &As...", "Salva &con nome..." },
+ { "&Export As Text...\tCtrl+E", "&Esportare il testo...\tCtrl+E" },
+ { "E&xit", "U&scita" },
+ { "&Undo\tCtrl+Z", "&Torna indietro\tCtrl+Z" },
+ { "&Redo\tCtrl+Y", "&Rifare\tCtrl+Y" },
+ { "Insert Rung &Before\tShift+6", "Inserire Ramo &Davanti\tShift+6" },
+ { "Insert Rung &After\tShift+V", "Inserire Ramo &Dietro\tShift+V" },
+ { "Move Selected Rung &Up\tShift+Up", "Muove il Ramo selezionato &Su\tShift+Up" },
+ { "Move Selected Rung &Down\tShift+Down", "Muove il Ramo selezionato &Giù\tShift+Down" },
+ { "&Delete Selected Element\tDel", "&Cancella l'elemento selezionato\tDel" },
+ { "D&elete Rung\tShift+Del", "Cancellare il Ramo\tShift+Del" },
+ { "Insert Co&mment\t;", "Inserire Co&mmento\t;" },
+ { "Insert &Contacts\tC", "Inserire &Contatto\tC" },
+ { "Insert OSR (One Shot Rising)\t&/", "Inserire PULSUP (Fronte di salita)\t&/" },
+ { "Insert OSF (One Shot Falling)\t&\\", "Inserire PULSDW (Fronte di discesa)\t&\\" },
+ { "Insert T&ON (Delayed Turn On)\tO", "Inserire T&ON (Tempo di ritardo On)\tO" },
+ { "Insert TO&F (Delayed Turn Off)\tF", "Inserire TO&F (Tempo di ritardo Off)\tF" },
+ { "Insert R&TO (Retentive Delayed Turn On)\tT", "Inserire R&TO (Tempo di ritardo ritentivo On)\tT" },
+ { "Insert CT&U (Count Up)\tU", "Inserire CT&U (Contatore Up)\tU" },
+ { "Insert CT&D (Count Down)\tI", "Inserire CT&D (Contatore Down)\tI" },
+ { "Insert CT&C (Count Circular)\tJ", "Inserire CT&C (Contatore ciclico)\tJ" },
+ { "Insert EQU (Compare for Equals)\t=", "Inserire EQU (Compara per Uguale)\t=" },
+ { "Insert NEQ (Compare for Not Equals)", "Inserire NEQ (Compara per Diverso)" },
+ { "Insert GRT (Compare for Greater Than)\t>", "Inserire GRT (Compara per Maggiore)\t>" },
+ { "Insert GEQ (Compare for Greater Than or Equal)\t.", "Inserire GEQ (Compara per Maggiore o Uguale)\t." },
+ { "Insert LES (Compare for Less Than)\t<", "Inserire LES (Compara per Minore)\t<" },
+ { "Insert LEQ (Compare for Less Than or Equal)\t,", "Inserire LEQ (Compara per Minore o Uguale)\t," },
+ { "Insert Open-Circuit", "Inserire Circuito Aperto" },
+ { "Insert Short-Circuit", "Inserire Corto Circuito" },
+ { "Insert Master Control Relay", "Inserire Master Control Relay" },
+ { "Insert Coi&l\tL", "Inserire Bobina Re&lè\tL" },
+ { "Insert R&ES (Counter/RTO Reset)\tE", "Inserire R&ES (Contatore/RTO Reset)\tE" },
+ { "Insert MOV (Move)\tM", "Inserire MOV (Spostare)\tM" },
+ { "Insert ADD (16-bit Integer Add)\t+", "Inserire ADD (Addizione intera 16-bit)\t+" },
+ { "Insert SUB (16-bit Integer Subtract)\t-", "Inserire SUB (Sottrazione intera 16-bit)\t-" },
+ { "Insert MUL (16-bit Integer Multiply)\t*", "Inserire MUL (Moltiplicazione intera 16-bit)\t*" },
+ { "Insert DIV (16-bit Integer Divide)\tD", "Inserire DIV (Divisione intera 16-bit)\tD" },
+ { "Insert Shift Register", "Inserire Shift Register" },
+ { "Insert Look-Up Table", "Inserire Tavola Indicizzata" },
+ { "Insert Piecewise Linear", "Inserire Tavola di Elementi Lineari" },
+ { "Insert Formatted String Over UART", "Inserire Stringhe Formattate per l'UART" },
+ { "Insert &UART Send", "Inserire Trasmissione &UART" },
+ { "Insert &UART Receive", "Inserire Ricezione &UART" },
+ { "Insert Set PWM Output", "Inserire Valore di Uscita PWM" },
+ { "Insert A/D Converter Read\tP", "Inserire Lettura del Convertitore A/D\tP" },
+ { "Insert Make Persistent", "Inserire Scrittura Permanente" },
+ { "Make Norm&al\tA", "Attivazione Norm&ale\tA" },
+ { "Make &Negated\tN", "Attivazione &Negata\tN" },
+ { "Make &Set-Only\tS", "Attivazione &Solo-Set\tS" },
+ { "Make &Reset-Only\tR", "Attivazione &Solo-Reset\tR" },
+ { "&MCU Parameters...", "&Parametri MCU..." },
+ { "(no microcontroller)", "(nessun microcontroller)" },
+ { "&Microcontroller", "&Microcontroller" },
+ { "Si&mulation Mode\tCtrl+M", "Modo Si&mulazione\tCtrl+M" },
+ { "Start &Real-Time Simulation\tCtrl+R", "Avviare la &Simulazione in Tempo Reale\tCtrl+R" },
+ { "&Halt Simulation\tCtrl+H", "&Arrestare la Simulazione\tCtrl+H" },
+ { "Single &Cycle\tSpace", "Singolo &Ciclo\tSpazio" },
+ { "&Compile\tF5", "&Compila\tF5" },
+ { "Compile &As...", "Compila &Come..." },
+ { "&Manual...\tF1", "&Manuale...\tF1" },
+ { "&About...", "&About..." },
+ { "&File", "&File" },
+ { "&Edit", "&Editazione" },
+ { "&Settings", "&Settaggi" },
+ { "&Instruction", "&Istruzione" },
+ { "Si&mulate", "Si&mulazione" },
+ { "&Compile", "&Compilazione" },
+ { "&Help", "&Aiuto" },
+ { "no MCU selected", "nessuna MCU selezionata" },
+ { "cycle time %.2f ms", "tempo ciclo %.2f ms" },
+ { "processor clock %.4f MHz", "clock processore %.4f MHz" },
+ { "Internal error relating to PIC paging; make program smaller or reshuffle it.", "Errore interno relativo allla paginazione PIC; rendere il programma più piccolo." },
+ { "PWM frequency too fast.", "Frequenza PWM troppo alta." },
+ { "PWM frequency too slow.", "Frequenza PWM tropppo lenta." },
+ { "Cycle time too fast; increase cycle time, or use faster crystal.", "Tempo di ciclo troppo veloce; aumentare il tempo di ciclo o utilizzare un quarzo più veloce." },
+ { "Cycle time too slow; decrease cycle time, or use slower crystal.", "Tempo di ciclo troppo lento; diminuire il tempo di ciclo o utilizzare un quarzo più lento." },
+ { "Couldn't open file '%s'", "Impossibile aprire il file '%s'" },
+ { "Zero baud rate not possible.", "baud rate = Zero non è possibile" },
+ { "Compile successful; wrote IHEX for PIC16 to '%s'.\r\n\r\nConfiguration word (fuses) has been set for crystal oscillator, BOD enabled, LVP disabled, PWRT enabled, all code protection off.\r\n\r\nUsed %d/%d words of program flash (chip %d%% full).", "Compilato con successo; scritto IHEX per PIC16 per '%s'.\r\n\r\nConfigurazione word (fusibili), è stato fissato per il cristallo oscillatore, BOD abilitato, LVP disabilitati, PWRT attivato, tutto il codice di protezione off.\r\n\r\nUsed %d/%d word di Programma flash (chip %d%% full)." },
+ { "Type", "Tipo" },
+ { "Timer", "Temporizzazione" },
+ { "Counter", "Contatore" },
+ { "Reset", "Reset" },
+ { "OK", "OK" },
+ { "Cancel", "Cancellare" },
+ { "Empty textbox; not permitted.", "Spazio vuoto per testo; non è consentito" },
+ { "Bad use of quotes: <%s>", "Quota utilizzata scorretta: <%s>" },
+ { "Turn-On Delay", "Ritardo all' eccitazione" },
+ { "Turn-Off Delay", "Ritardo alla diseccitazione" },
+ { "Retentive Turn-On Delay", "Ritardo Ritentivo all' eccitazione" },
+ { "Delay (ms):", "Ritardo (ms):" },
+ { "Delay too long; maximum is 2**31 us.", "Ritardo troppo lungo; massimo 2**31 us." },
+ { "Delay cannot be zero or negative.", "Ritardo zero o negativo non possibile." },
+ { "Count Up", "Contatore in avanti" },
+ { "Count Down", "Contatore in discesa" },
+ { "Circular Counter", "Contatore ciclico" },
+ { "Max value:", "Valore massimo:" },
+ { "True if >= :", "Vero se >= :" },
+ { "If Equals", "Se Uguale" },
+ { "If Not Equals", "Se non Uguale" },
+ { "If Greater Than", "Se più grande di" },
+ { "If Greater Than or Equal To", "Se più grande o uguale di" },
+ { "If Less Than", "Se più piccolo di" },
+ { "If Less Than or Equal To", "Se più piccolo o uguale di" },
+ { "'Closed' if:", "Chiuso se:" },
+ { "Move", "Spostare" },
+ { "Read A/D Converter", "Lettura del convertitore A/D" },
+ { "Duty cycle var:", "Duty cycle var:" },
+ { "Frequency (Hz):", "Frequenza (Hz):" },
+ { "Set PWM Duty Cycle", "Settare PWM Duty Cycle" },
+ { "Source:", "Sorgente:" },
+ { "Receive from UART", "Ricezione dall' UART" },
+ { "Send to UART", "Trasmissione all' UART" },
+ { "Add", "Addizione" },
+ { "Subtract", "Sottrazione" },
+ { "Multiply", "Moltiplicazione" },
+ { "Divide", "Divisione" },
+ { "Destination:", "Destinazione:" },
+ { "is set := :", "é impostato := :" },
+ { "Name:", "Nome:" },
+ { "Stages:", "Stati:" },
+ { "Shift Register", "Registro a scorrimento" },
+ { "Not a reasonable size for a shift register.", "Non è una dimensione ragionevole per un registro scorrimento." },
+ { "String:", "Stringhe:" },
+ { "Formatted String Over UART", "Stringhe formattate per l'UART" },
+ { "Variable:", "Variabile:" },
+ { "Make Persistent", "Memoria rimanante" },
+ { "Too many elements in subcircuit!", "Troppi elementi nel circuito secondario!" },
+ { "Too many rungs!", "Troppi rami!" },
+ { "Error", "Errore" },
+ { "ANSI C target does not support peripherals (UART, PWM, ADC, EEPROM). Skipping that instruction.", "Il codice in uscita ANSI C non supporta queste istruzioni (UART, PWM, ADC, EEPROM). Non usare queste istruzioni." },
+ { "Compile successful; wrote C source code to '%s'.\r\n\r\nThis is not a complete C program. You have to provide the runtime and all the I/O routines. See the comments in the source code for information about how to do this.", "Compilato con successo; scritto il codice sorgente in C '%s'.\r\n\r\nIl non è un completo programma in C. Si deve fornire il runtime e tutti gli I / O di routine. Vedere i commenti nel codice sorgente per informazioni su come fare." },
+ { "Cannot delete rung; program must have at least one rung.", "Non è in grado di eliminare le linee; il programma deve avere almeno una linea." },
+ { "Out of memory; simplify program or choose microcontroller with more memory.", "Memoria insufficiente; semplificare il programma oppure scegliere microcontrollori con più memoria ." },
+ { "Must assign pins for all ADC inputs (name '%s').", "Devi assegnare i pin per tutti gli ingressi ADC (nom '%s')." },
+ { "Internal limit exceeded (number of vars)", "Superato il limite interno (numero di variabili)" },
+ { "Internal relay '%s' never assigned; add its coil somewhere.", "Relè interno '%s' non assegnato; aggiungere la sua bobina." },
+ { "Must assign pins for all I/O.\r\n\r\n'%s' is not assigned.", "Devi assegnare tutti i pin di I / O.\r\n\r\n'%s' non è stato assegnato." },
+ { "UART in use; pins %d and %d reserved for that.", "UART in uso; pins %d et %d riservati per questa." },
+ { "PWM in use; pin %d reserved for that.", "PWM utilizzato; pin %d riservati per questo." },
+ { "UART baud rate generator: divisor=%d actual=%.4f for %.2f%% error.\r\n\r\nThis is too large; try a different baud rate (slower probably), or a crystal frequency chosen to be divisible by many common baud rates (e.g. 3.6864 MHz, 14.7456 MHz).\r\n\r\nCode will be generated anyways but serial may be unreliable or completely broken.", "UART generatore di baud rate: divisore = %d effettivo = %.4f per %.2f%% di errore.\r\n\r\nIl è troppo grande; prova un altro baud rate (probabilmente più lento), o il quarzo scelto non è divisibile per molti comuni baud (ad esempio, 3.6864 MHz, 14.7456 MHz).\r\n\r\nIl codice verrà generato, ma comunque può essere inaffidabile o completamente non funzionante." },
+ { "UART baud rate generator: too slow, divisor overflows. Use a slower crystal or a faster baud rate.\r\n\r\nCode will be generated anyways but serial will likely be completely broken.", "UART generatore di baud rate: troppo lento, overflow. Utilizzare un quarzo più lento o una velocità più alta di baud.\r\n\r\nIl codice verrà generato, ma comunque sarà probabilmente completamente inutilizzabile." },
+ { "Couldn't open '%s'\n", "Impossibile aprire '%s'\n" },
+ { "Timer period too short (needs faster cycle time).", "Periodo troppo corto (Diminuire il tempo de ciclo)." },
+ { "Timer period too long (max 32767 times cycle time); use a slower cycle time.", "Tempo troppo lungo (max 32767 volte di ciclo); utilizzare un tempo di ciclo più lento." },
+ { "Constant %d out of range: -32768 to 32767 inclusive.", "Costante %d oltre il limite: -32768 a 32767 inclusi." },
+ { "Move instruction: '%s' not a valid destination.", "Sposta istruzione: '%s' non è una destinazione valida." },
+ { "Math instruction: '%s' not a valid destination.", "Math istruzione: '%s' non è una destinazione valida" },
+ { "Piecewise linear lookup table with zero elements!", "La tabella lineare di ricerca non contiene elementi!" },
+ { "x values in piecewise linear table must be strictly increasing.", "X valori nella tabella lineare devono essere crescenti." },
+ { "Numerical problem with piecewise linear lookup table. Either make the table entries smaller, or space the points together more closely.\r\n\r\nSee the help file for details.", "Problema numerico con la tabella lineare di ricerca. Sia la tabella voci più piccole, o insieme di punti più vicini.\r\n\r\nVedere il file di aiuto per ulteriori dettagli." },
+ { "Multiple escapes (\\0-9) present in format string, not allowed.", "Uscita multipla (\\0-9) presente nel formato stringa, non consentito." },
+ { "Bad escape: correct form is \\xAB.", "Uscita errata: Forma non corretta = \\xAB." },
+ { "Bad escape '\\%c'", "Uscita non corretta '\\%c'" },
+ { "Variable is interpolated into formatted string, but none is specified.", "Variabile interpolata in formato stringa, ma non è specificata." },
+ { "No variable is interpolated into formatted string, but a variable name is specified. Include a string like '\\-3', or leave variable name blank.", "Variabile interpolata non in formato stringa, ma un nome di variabile è stato specificato. Includi una stringa come '\\-3', o lasciare vuoto." },
+ { "Empty row; delete it or add instructions before compiling.", "Riga vuota, eliminare o aggiungere istruzioni prima di compilare." },
+ { "Couldn't write to '%s'", "Impossibile scrivere qui '%s'." },
+ { "Unsupported op (anything ADC, PWM, UART, EEPROM) for interpretable target.", "Istruzioni non supportate (come ADC, PWM, UART, EEPROM ) per il codice interpretato." },
+ { "Compile successful; wrote interpretable code to '%s'.\r\n\r\nYou probably have to adapt the interpreter to your application. See the documentation.", "Compilazione riuscita; codice interpretabile scritto per '%s'.\r\n\r\nSi dovrà probabilmente adattare l'interprete per la vostra applicazione. Vedi la documentazione." },
+ { "Microcontroller '%s' not supported.\r\n\r\nDefaulting to no selected MCU.", "Microcontrollore '%s' non è supportato.\r\n\r\nNessuna MCU selezionata di default." },
+ { "File format error; perhaps this program is for a newer version of LDmicro?", "Errore del formato del file, forse questo è il programma per una nuova versione di LDmicro?" },
+ { "Index:", "Indice:" },
+ { "Points:", "Punto:" },
+ { "Count:", "Contatore:" },
+ { "Edit table of ASCII values like a string", "Modifica tabella dei valori ASCII come stringa" },
+ { "Look-Up Table", "Tabella indicizzata" },
+ { "Piecewise Linear Table", "Tabella di elementi lineari" },
+ { "LDmicro Error", "Errore LDmicro" },
+ { "Compile Successful", "Compilato con successo" },
+ { "digital in", "Input digitale" },
+ { "digital out", "Uscita digitale" },
+ { "int. relay", "Relè interno" },
+ { "UART tx", "UART tx" },
+ { "UART rx", "UART rx" },
+ { "PWM out", "Uscita PWM" },
+ { "turn-on delay", "ritardo all' eccitazione" },
+ { "turn-off delay", "ritardo alla diseccitazione" },
+ { "retentive timer", "ritardo ritentivo" },
+ { "counter", "contatore" },
+ { "general var", "Var. generale" },
+ { "adc input", "Ingrasso ADC" },
+ { "<corrupt!>", "<Corrotto!>" },
+ { "(not assigned)", "(non assegnato)" },
+ { "<no UART!>", "<nessuna UART!>" },
+ { "<no PWM!>", "<nessun PWM!>" },
+ { "TOF: variable cannot be used elsewhere", "TOF: la variabile non può essere utilizzata altrove" },
+ { "TON: variable cannot be used elsewhere", "TON: la variabile non può essere utilizzata altrove" },
+ { "RTO: variable can only be used for RES elsewhere", "RTO: la variabile può essere utilizzata altrove solo per il RES" },
+ { "Variable '%s' not assigned to, e.g. with a MOV statement, an ADD statement, etc.\r\n\r\nThis is probably a programming error; now it will always be zero.", "Variabile '%s' non assegnate, ad esempio, con una dichiarazione, MOV, una dichiarazione ADD, ecc\r\n\r\nQuesto è probabilmente un errore di programmazione; ora sarà sempre uguale a zero." },
+ { "Variable for '%s' incorrectly assigned: %s.", "Variabile per '%s' assegnazione incorretta: %s." },
+ { "Division by zero; halting simulation", "Divisione per zero; Simulazione fermata" },
+ { "!!!too long!!!", "!troppo lungo!" },
+ { "\n\nI/O ASSIGNMENT:\n\n", "\n\nE/S ASSEGNAZIONE:\n\n" },
+ { " Name | Type | Pin\n", " Nome | Type | Pin\n" },
+};
+static Lang LangIt = {
+ LangItTable, sizeof(LangItTable)/sizeof(LangItTable[0])
+};
+#endif
+#ifdef LDLANG_PT
+static LangTable LangPtTable[] = {
+ { "Target frequency %d Hz, closest achievable is %d Hz (warning, >5%% error).", "Freqüência do Micro %d Hz, a melhor aproximação é %d Hz (aviso, >5%% error)." },
+ { "Compile successful; wrote IHEX for AVR to '%s'.\r\n\r\nRemember to set the processor configuration (fuses) correctly. This does not happen automatically.", "Compilação sucedida; se escrito em IHEX para AVR para '%s'.\r\n\r\nLembrar de anotar as configurações (fuses) do micro, corretamente. Isto não acontece automaticamente." },
+ { "( ) Normal", "( ) Normal" },
+ { "(/) Negated", "(/) Negado" },
+ { "(S) Set-Only", "(S) Ativar" },
+ { "(R) Reset-Only", "(R) Desativar" },
+ { "Pin on MCU", "Pino no Micro" },
+ { "Coil", "Bobina" },
+ { "Comment", "Comentário" },
+ { "Cycle Time (ms):", "Tempo de Ciclo (ms):" },
+ { "Crystal Frequency (MHz):", "Freqüência Cristal (MHz):" },
+ { "UART Baud Rate (bps):", "Baud Rate UART (bps):" },
+ { "Serie (UART) will use pins %d and %d.\r\n\r\n", "Porta Serial (UART) usará os pinos %d e %d.\r\n\r\n" },
+ { "Please select a micro with a UART.\r\n\r\n", "Por favor, selecione um micro com UART.\r\n\r\n" },
+ { "No serial instructions (UART Send/UART Receive) are in use; add one to program before setting baud rate.\r\n\r\n", "Nenhuma instrução serial (UART Enviar/UART Recebe) está em uso; adicione uma ao programa antes de configurar a taxa de transmissão (baud rate).\r\n\r\n" },
+ { "The cycle time for the 'PLC' runtime generated by LDmicro is user-configurable. Very short cycle times may not be achievable due to processor speed constraints, and very long cycle times may not be achievable due to hardware overflows. Cycle times between 10 ms and 100 ms will usually be practical.\r\n\r\nThe compiler must know what speed crystal you are using with the micro to convert between timing in clock cycles and timing in seconds. A 4 MHz to 20 MHz crystal is typical; check the speed grade of the part you are using to determine the maximum allowable clock speed before choosing a crystal.", "O tempo de ciclo para o PLC generalizado pelo LDmicro é configuravel pelo usuário. Tempos de ciclo muito pequenos podem não ser realizáveis devido a baixa velocidade do processador, e tempos de ciclo muito longos podem não ser realizáveis devido ao temporizador do micro. Ciclos de tempo entre 10 e 100ms são mais usuais.\r\n\r\n O compilador tem que saber qual é a freqüência do cristal que está sendo usado para poder converter entre o tempo em ciclos do clock e tempo em segundos. Cristais entre 4 Mhz e 20 Mhz são os mais típicos. Confira a velocidade que pode funcionar seu micro e calcule a velocidade máxima do clock antes de encolher o cristal." },
+ { "PLC Configuration", "Configuração PLC" },
+ { "Zero cycle time not valid; resetting to 10 ms.", "Não é válido um tempo de ciclo 0; retornando a 10 ms." },
+ { "Source", "Fonte" },
+ { "Internal Relay", "Rele Interno" },
+ { "Input pin", "Pino Entrada" },
+ { "Output pin", "Pino Saida" },
+ { "|/| Negated", "|/| Negado" },
+ { "Contacts", "Contatos" },
+ { "No ADC or ADC not supported for selected micro.", "O micro selecionado não possui ADC ou não suporta." },
+ { "Assign:", "Atribua:" },
+ { "No microcontroller has been selected. You must select a microcontroller before you can assign I/O pins.\r\n\r\nSelect a microcontroller under the Settings menu and try again.", "Nenhum micro esta selecionado. Você deve selecionar um micro antes de atribuir os pinos E/S.\r\n\r\nSelecione um micro no menu de configuração e tente novamente." },
+ { "I/O Pin Assignment", "Atribuição de Pinos de E/S" },
+ { "Can't specify I/O assignment for ANSI C target; compile and see comments in generated source code.", "Não se pode atribuir as E/S especificadas para o ANSI C gerado; compile e veja os comentários gerados no código fonte." },
+ { "Can't specify I/O assignment for interpretable target; see comments in reference implementation of interpreter.", "Não se pode atribuir as E/S especificadas para o código gerado para o interpretador; veja os comentários na implementação do interpretador." },
+ { "Can only assign pin number to input/output pins (Xname or Yname or Aname).", "Somente pode atribuir números dos pinos aos pinos de Entrada/Saída (Xname ou Yname ou Aname)." },
+ { "No ADC or ADC not supported for this micro.", "Este micro não tem ADC ou não é suportado." },
+ { "Rename I/O from default name ('%s') before assigning MCU pin.", "Renomear as E/S para nome padrão ('%s') antes de atribuir um pino do micro." },
+ { "I/O Pin", "Pino E/S" },
+ { "(no pin)", "(sem pino)" },
+ { "<UART needs!>", "<Se necessitar UART!>" },
+ { "<PWM needs!>", "<Se necessitar PWM!>" },
+ { "<not an I/O!>", "<Não é uma E/S!>" },
+ { "Export As Text", "Exportar como Texto" },
+ { "Couldn't write to '%s'.", "Não pode gravar para '%s'." },
+ { "Compile To", "Compilar Para" },
+ { "Must choose a target microcontroller before compiling.", "Deve selecionar um microcontrolador antes de compilar." },
+ { "UART function used but not supported for this micro.", "Função UART é usada porem não suportada por este micro." },
+ { "PWM function used but not supported for this micro.", "Função PWM é usada porem não suportada por este micro." },
+ { "The program has changed since it was last saved.\r\n\r\nDo you want to save the changes?", "Este programa contem mudanças desde a ultima vez salva.\r\n\r\n Você quer salvar as mudanças?" },
+ { "--add comment here--", "--Adicione Comentários Aqui--" },
+ { "Start new program?", "Iniciar um novo programa?" },
+ { "Couldn't open '%s'.", "Não pode abrir '%s'." },
+ { "Name", "Nome" },
+ { "State", "Estado" },
+ { "Pin on Processor", "Pino do Processador" },
+ { "MCU Port", "Porta do Micro" },
+ { "LDmicro - Simulation (Running)", "LDmicro - Simulação (Executando)" },
+ { "LDmicro - Simulation (Stopped)", "LDmicro - Simulação (Parado)" },
+ { "LDmicro - Program Editor", "LDmicro - Editor de Programa" },
+ { " - (not yet saved)", " - (ainda não salvo)" },
+ { "&New\tCtrl+N", "&Novo\tCtrl+N" },
+ { "&Open...\tCtrl+O", "&Abrir...\tCtrl+O" },
+ { "&Save\tCtrl+S", "&Salvar\tCtrl+S" },
+ { "Save &As...", "Salvar &Como..." },
+ { "&Export As Text...\tCtrl+E", "&Exportar como Texto...\tCtrl+E" },
+ { "E&xit", "&Sair" },
+ { "&Undo\tCtrl+Z", "&Desfazer\tCtrl+Z" },
+ { "&Redo\tCtrl+Y", "&Refazer\tCtrl+Y" },
+ { "Insert Rung &Before\tShift+6", "Inserir Linha (Rung) &Antes\tShift+6" },
+ { "Insert Rung &After\tShift+V", "Inserir Linha (Rung) &Depois\tShift+V" },
+ { "Move Selected Rung &Up\tShift+Up", "Mover Linha Selecionada (Rung) &Acima\tShift+Up" },
+ { "Move Selected Rung &Down\tShift+Down", "Mover Linha Selecionada(Rung) &Abaixo\tShift+Down" },
+ { "&Delete Selected Element\tDel", "&Apagar Elemento Selecionado\tDel" },
+ { "D&elete Rung\tShift+Del", "A&pagar Linha (Rung) \tShift+Del" },
+ { "Insert Co&mment\t;", "Inserir Co&mentário\t;" },
+ { "Insert &Contacts\tC", "Inserir &Contatos\tC" },
+ { "Insert OSR (One Shot Rising)\t&/", "Inserir OSR (Detecta Borda de Subida)\t&/" },
+ { "Insert OSF (One Shot Falling)\t&\\", "Inserir OSF (Detecta Borda de Descida)\t&\\" },
+ { "Insert T&ON (Delayed Turn On)\tO", "Inserir T&ON (Temporizador para Ligar)\tO" },
+ { "Insert TO&F (Delayed Turn Off)\tF", "Inserir TO&F (Temporizador para Desligar)\tF" },
+ { "Insert R&TO (Retentive Delayed Turn On)\tT", "Inserir R&TO (Temporizar Retentivo para Ligar)\tT" },
+ { "Insert CT&U (Count Up)\tU", "Inserir CT&U (Contador Incremental)\tU" },
+ { "Insert CT&D (Count Down)\tI", "Inserir CT&D (Contador Decremental)\tI" },
+ { "Insert CT&C (Count Circular)\tJ", "Inserir CT&C (Contador Circular)\tJ" },
+ { "Insert EQU (Compare for Equals)\t=", "Inserir EQU (Comparar se é Igual)\t=" },
+ { "Insert NEQ (Compare for Not Equals)", "Inserir NEQ (Comparar se é Diferente)" },
+ { "Insert GRT (Compare for Greater Than)\t>", "Inserir GRT (Comparar se Maior Que)\t>" },
+ { "Insert GEQ (Compare for Greater Than or Equal)\t.", "Inserir GEQ (Comparar se Maior ou Igual Que)\t." },
+ { "Insert LES (Compare for Less Than)\t<", "Inserir LES (Comparar se Menor Que)\t<" },
+ { "Insert LEQ (Compare for Less Than or Equal)\t,", "Inserir LEQ (Comparar se Menor ou Igual Que)\t," },
+ { "Insert Open-Circuit", "Inserir Circuito Aberto" },
+ { "Insert Short-Circuit", "Inserir Curto Circuito" },
+ { "Insert Master Control Relay", "Inserir Rele de Controle Mestre" },
+ { "Insert Coi&l\tL", "Inserir &Bobina\tL" },
+ { "Insert R&ES (Counter/RTO Reset)\tE", "Inserir R&ES (Contador/RTO Reinicia)\tE" },
+ { "Insert MOV (Move)\tM", "Inserir MOV (Mover)\tM" },
+ { "Insert ADD (16-bit Integer Add)\t+", "Inserir ADD (Soma Inteiro 16-bit)\t+" },
+ { "Insert SUB (16-bit Integer Subtract)\t-", "Inserir SUB (Subtrair Inteiro 16-bit)\t-" },
+ { "Insert MUL (16-bit Integer Multiply)\t*", "Inserir MUL (Multiplica Inteiro 16-bit)\t*" },
+ { "Insert DIV (16-bit Integer Divide)\tD", "Inserir DIV (Divide Inteiro 16-bit)\tD" },
+ { "Insert Shift Register", "Inserir Registro de Troca" },
+ { "Insert Look-Up Table", "Inserir Tabela de Busca" },
+ { "Insert Piecewise Linear", "Inserir Linearização por Segmentos" },
+ { "Insert Formatted String Over UART", "Inserir String Formatada na UART" },
+ { "Insert &UART Send", "Inserir &UART Enviar" },
+ { "Insert &UART Receive", "Inserir &UART Receber" },
+ { "Insert Set PWM Output", "Inserir Valor de Saída PWM" },
+ { "Insert A/D Converter Read\tP", "Inserir Leitura do Conversor A/D\tP" },
+ { "Insert Make Persistent", "Inserir Fazer Permanente" },
+ { "Make Norm&al\tA", "Fazer Norm&al\tA" },
+ { "Make &Negated\tN", "Fazer &Negado\tN" },
+ { "Make &Set-Only\tS", "Fazer &Ativar-Somente\tS" },
+ { "Make &Reset-Only\tR", "Fazer&Desativar-Somente\tR" },
+ { "&MCU Parameters...", "&Parâmetros do Micro..." },
+ { "(no microcontroller)", "(sem microcontrolador)" },
+ { "&Microcontroller", "&Microcontrolador" },
+ { "Si&mulation Mode\tCtrl+M", "Modo Si&mulação \tCtrl+M" },
+ { "Start &Real-Time Simulation\tCtrl+R", "Iniciar Simulação em Tempo &Real\tCtrl+R" },
+ { "&Halt Simulation\tCtrl+H", "Parar Simulação\tCtrl+H" },
+ { "Single &Cycle\tSpace", "Simples &Ciclo\tEspaço" },
+ { "&Compile\tF5", "&Compilar\tF5" },
+ { "Compile &As...", "Compilar &Como..." },
+ { "&Manual...\tF1", "&Manual...\tF1" },
+ { "&About...", "&Sobre..." },
+ { "&File", "&Arquivo" },
+ { "&Edit", "&Editar" },
+ { "&Settings", "&Configurações" },
+ { "&Instruction", "&Instruções" },
+ { "Si&mulate", "Si&mular" },
+ { "&Compile", "&Compilar" },
+ { "&Help", "&Ajuda" },
+ { "no MCU selected", "Micro não selecionado" },
+ { "cycle time %.2f ms", "tempo de ciclo %.2f ms" },
+ { "processor clock %.4f MHz", "clock do processador %.4f MHz" },
+ { "Internal error relating to PIC paging; make program smaller or reshuffle it.", "Erro interno relativo a paginação do PIC; fazer um programa menor ou reorganiza-lo" },
+ { "PWM frequency too fast.", "Freqüência do PWM muito alta." },
+ { "PWM frequency too slow.", "Freqüência do PWM muito baixa." },
+ { "Cycle time too fast; increase cycle time, or use faster crystal.", "Tempo de Ciclo muito rápido; aumentar tempo do ciclo, ou usar um cristal de maior Mhz." },
+ { "Cycle time too slow; decrease cycle time, or use slower crystal.", "Tempo de Ciclo muito lento; diminuir tempo do ciclo, ou usar um cristal de menor Mhz." },
+ { "Couldn't open file '%s'", "Não pode abrir o arquivo '%s'" },
+ { "Zero baud rate not possible.", "Zero Baud Rate não é possível." },
+ { "Compile successful; wrote IHEX for PIC16 to '%s'.\r\n\r\nConfiguration word (fuses) has been set for crystal oscillator, BOD enabled, LVP disabled, PWRT enabled, all code protection off.\r\n\r\nUsed %d/%d words of program flash (chip %d%% full).", "Compilação sucedida; escrito IHEX para PIC16 em '%s'.\r\n\r\nBits de Configuração (fuses) foi estabelecido para o cristal oscilador, BOD ativado, LVP desativado, PWRT ativado, Todos os bits de proteção desativados.\r\n\r\nUsadas %d/%d palavras de programa em flash (Chip %d%% completo)." },
+ { "Type", "Tipo" },
+ { "Timer", "Temporizador" },
+ { "Counter", "Contador" },
+ { "Reset", "Reiniciar" },
+ { "OK", "OK" },
+ { "Cancel", "Cancelar" },
+ { "Empty textbox; not permitted.", "Texto vazio; não é permitido" },
+ { "Bad use of quotes: <%s>", "Mau uso das aspas: <%s>" },
+ { "Turn-On Delay", "Temporizador para Ligar" },
+ { "Turn-Off Delay", "Temporizador para Desligar" },
+ { "Retentive Turn-On Delay", "Temporizador Retentivo para Ligar" },
+ { "Delay (ms):", "Tempo (ms):" },
+ { "Delay too long; maximum is 2**31 us.", "Tempo muito longo; Maximo 2**31 us." },
+ { "Delay cannot be zero or negative.", "Tempo não pode ser zero ou negativo." },
+ { "Count Up", "Contador Crescente" },
+ { "Count Down", "Contador Decrescente" },
+ { "Circular Counter", "Contador Circular" },
+ { "Max value:", "Valor Max:" },
+ { "True if >= :", "Verdadeiro se >= :" },
+ { "If Equals", "Se Igual" },
+ { "If Not Equals", " Se Diferente" },
+ { "If Greater Than", "Se Maior Que" },
+ { "If Greater Than or Equal To", "Se Maior ou Igual Que" },
+ { "If Less Than", "Se Menor Que" },
+ { "If Less Than or Equal To", "Se Menor ou Igual Que" },
+ { "'Closed' if:", "'Fechado' se:" },
+ { "Move", "Mover" },
+ { "Read A/D Converter", "Ler Conversor A/D" },
+ { "Duty cycle var:", "Var Duty cycle:" },
+ { "Frequency (Hz):", "Frequencia (Hz):" },
+ { "Set PWM Duty Cycle", "Acionar PWM Duty Cycle" },
+ { "Source:", "Fonte:" },
+ { "Receive from UART", "Recebe da UART" },
+ { "Send to UART", "Envia para UART" },
+ { "Add", "Somar" },
+ { "Subtract", "Subtrair" },
+ { "Multiply", "Multiplicar" },
+ { "Divide", "Dividir" },
+ { "Destination:", "Destino:" },
+ { "is set := :", "esta acionado := :" },
+ { "Name:", "Nome:" },
+ { "Stages:", "Fases:" },
+ { "Shift Register", "Deslocar Registro" },
+ { "Not a reasonable size for a shift register.", "Não é um tamanho razoável para um registro de deslocamento." },
+ { "String:", "String:" },
+ { "Formatted String Over UART", "String Formatada para UART" },
+ { "Variable:", "Variavel:" },
+ { "Make Persistent", "Fazer Permanente" },
+ { "Too many elements in subcircuit!", "Excesso de elementos no SubCircuito!" },
+ { "Too many rungs!", "Muitas Linhas (rungs)!" },
+ { "Error", "Error" },
+ { "ANSI C target does not support peripherals (UART, PWM, ADC, EEPROM). Skipping that instruction.", "ANSI C não suporta periféricos (UART, PWM, ADC, EEPROM). Evite essas instruções." },
+ { "Compile successful; wrote C source code to '%s'.\r\n\r\nThis is not a complete C program. You have to provide the runtime and all the I/O routines. See the comments in the source code for information about how to do this.", "Compilação sucedida: Código Fonte escrito em C para '%s'.\r\n\r\nEste programa nao é completo em C. Você tem que fornecer o tempo de execução e de todas as rotinas de E/S. Veja os comentários no código fonte para mais informação sobre como fazer isto." },
+ { "Cannot delete rung; program must have at least one rung.", "Não pode apagar a Linha (rung); O programa deve contem pelo menos uma Linha (rung)." },
+ { "Out of memory; simplify program or choose microcontroller with more memory.", "Fora de Memória; Simplifique o programa ou escolha um microcontrolador com mais memória." },
+ { "Must assign pins for all ADC inputs (name '%s').", "Deve associar pinos para todas as entradas do ADC (nome '%s')." },
+ { "Internal limit exceeded (number of vars)", "Limite interno excedido (numero de variáveis)" },
+ { "Internal relay '%s' never assigned; add its coil somewhere.", "Rele Interno'%s' não foi associado; adicione esta bobina em outro lugar." },
+ { "Must assign pins for all I/O.\r\n\r\n'%s' is not assigned.", "Deve associar pinos a todas E/S.\r\n\r\n'%s' não esta associado." },
+ { "UART in use; pins %d and %d reserved for that.", "UART em uso; pinos %d e %d reservado para isso." },
+ { "PWM in use; pin %d reserved for that.", "PWM em uso; pino %d reservada para isso." },
+ { "UART baud rate generator: divisor=%d actual=%.4f for %.2f%% error.\r\n\r\nThis is too large; try a different baud rate (slower probably), or a crystal frequency chosen to be divisible by many common baud rates (e.g. 3.6864 MHz, 14.7456 MHz).\r\n\r\nCode will be generated anyways but serial may be unreliable or completely broken.", "Gerador UART baud rate: divisor=%d atual=%.4f para %.2f%% error.\r\n\r\nEste é muito grande; Tente com outro valor (provavelmente menor), ou um cristal cuja freqüência seja divisível pelos baud rate mais comuns (p.e. 3.6864MHz, 14.7456MHz).\r\n\r\nO código será gerado de qualquer maneira, porem a serial poderá ser incerta ou completamente fragmentada." },
+ { "UART baud rate generator: too slow, divisor overflows. Use a slower crystal or a faster baud rate.\r\n\r\nCode will be generated anyways but serial will likely be completely broken.", "Gerador UART baud rate: muito lento, divisor excedido. Use um cristal mais lento ou um baud rate maior.\r\n\r\nO código será gerado de qualquer maneira, porem a serial poderá ser incerta ou completamente fragmentada.." },
+ { "Couldn't open '%s'\n", "Não pode abrir '%s'\n" },
+ { "Timer period too short (needs faster cycle time).", "Período de Tempo muito curto (necessitara de um tempo de ciclo maior)." },
+ { "Timer period too long (max 32767 times cycle time); use a slower cycle time.", "Tempo do Temporizador muito grande(max. 32767 tempo de ciclo); use um tempo de ciclo menor." },
+ { "Constant %d out of range: -32768 to 32767 inclusive.", "Constante %d fora do range: -32768 a 32767 inclusive." },
+ { "Move instruction: '%s' not a valid destination.", "Instrução Mover: '%s' o destino não é válido." },
+ { "Math instruction: '%s' not a valid destination.", "Instruções Math: '%s' o destino não é válido." },
+ { "Piecewise linear lookup table with zero elements!", "Consulta da Tabela de Linearização por Segmentos com elementos zero!" },
+ { "x values in piecewise linear table must be strictly increasing.", "Os valores X na Tabela de Linearização por Segmentos deve ser estritamente incrementais." },
+ { "Numerical problem with piecewise linear lookup table. Either make the table entries smaller, or space the points together more closely.\r\n\r\nSee the help file for details.", "Problema numérico com a Tabela de Linearização por segmentos. Faça qualquer tabela com entradas menores. ou espace os pontos para mais pròximo.\r\n\r\nVeja em ajuda para mais detalhes." },
+ { "Multiple escapes (\\0-9) present in format string, not allowed.", "Não é permitido mais de um caractere especial (\\0-9) dentro da string formatada." },
+ { "Bad escape: correct form is \\xAB.", "Caractere Especial com Erro: A forma correta é \\xAB." },
+ { "Bad escape '\\%c'", "Caractere Especial com Erro '\\%c'" },
+ { "Variable is interpolated into formatted string, but none is specified.", "A variável é interpolada dentro da string formatada, mas nenhuma é especificado." },
+ { "No variable is interpolated into formatted string, but a variable name is specified. Include a string like '\\-3', or leave variable name blank.", "Nenhuma variável esta interpolada dentro da string formatada, porem um nome de variável é especificada. Inclua uma string como '\\-3', ou deixe o nome da variável em branco." },
+ { "Empty row; delete it or add instructions before compiling.", "Linha Vazia; apague ou adicione instruções antes de compilar." },
+ { "Couldn't write to '%s'", "Não pode ser gravado para '%s'." },
+ { "Unsupported op (anything ADC, PWM, UART, EEPROM) for interpretable target.", "Op não suportada no interpretador (algum ADC, PWM, UART, EEPROM)." },
+ { "Compile successful; wrote interpretable code to '%s'.\r\n\r\nYou probably have to adapt the interpreter to your application. See the documentation.", "Compilação sucedida: Código para interpretador escrito para '%s'.\r\n\r\nVocê provavelmente tem que adaptar o interpretador para sua aplicação. Veja a documentação." },
+ { "Microcontroller '%s' not supported.\r\n\r\nDefaulting to no selected MCU.", "Microcontrolador '%s' não suportado.\r\n\r\nFalha nenhum Micro selecionado." },
+ { "File format error; perhaps this program is for a newer version of LDmicro?", "Erro no formato de arquivo; talvez este programa é para uma versão mais nova do LDmicro?." },
+ { "Index:", "Índice:" },
+ { "Points:", "Pontos:" },
+ { "Count:", "Contador:" },
+ { "Edit table of ASCII values like a string", "Editar tabela do ASCII, valores como uma string" },
+ { "Look-Up Table", "Buscar na Tabela" },
+ { "Piecewise Linear Table", "Tabela de Linearização por Segmentos" },
+ { "LDmicro Error", "LDmicro Error" },
+ { "Compile Successful", "Compilação Sucedida" },
+ { "digital in", "entrada digital" },
+ { "digital out", "saída digital" },
+ { "int. relay", "rele interno" },
+ { "UART tx", "UART tx" },
+ { "UART rx", "UART rx" },
+ { "PWM out", "saída PWM" },
+ { "turn-on delay", "ativar atraso" },
+ { "turn-off delay", "desativar atraso" },
+ { "retentive timer", "temporizador com memória" },
+ { "counter", "contador" },
+ { "general var", "var geral" },
+ { "adc input", "entrada adc" },
+ { "<corrupt!>", "<corrompido!>" },
+ { "(not assigned)", "(sem atribuição)" },
+ { "<no UART!>", "<sem UART!>" },
+ { "<no PWM!>", "<sem PWM!>" },
+ { "TOF: variable cannot be used elsewhere", "TOF: a variável não pode ser usada em outra parte" },
+ { "TON: variable cannot be used elsewhere", "TON: a variável não pode ser usada em outra parte" },
+ { "RTO: variable can only be used for RES elsewhere", "RTO: a variável somente pode ser usada como RES em outra parte" },
+ { "Variable '%s' not assigned to, e.g. with a MOV statement, an ADD statement, etc.\r\n\r\nThis is probably a programming error; now it will always be zero.", "variável '%s' não atribuída, p.e. com o comando MOV, comando ADD, etc.\r\n\r\nIsto é provavelmente um erro de programação; será sempre zero." },
+ { "Variable for '%s' incorrectly assigned: %s.", "Variável para '%s' atribuída incorretamente : %s." },
+ { "Division by zero; halting simulation", "Divisão por zero; Parando simulação" },
+ { "!!!too long!!!", "!Muito longo!" },
+ { "\n\nI/O ASSIGNMENT:\n\n", "\n\nE/S ATRIBUIDA:\n\n" },
+ { " Name | Type | Pin\n", " Nome | Tipo | Pino\n" },
+ { "Serial (UART) will use pins %d and %d.\r\n\r\n", "A porta Serial (UART) usará os pinos %d e %d.\r\n\r\n" },
+};
+static Lang LangPt = {
+ LangPtTable, sizeof(LangPtTable)/sizeof(LangPtTable[0])
+};
+#endif
+#ifdef LDLANG_TR
+static LangTable LangTrTable[] = {
+ { "Target frequency %d Hz, closest achievable is %d Hz (warning, >5%% error).", "Hedef frekans %d Hz, bu değere en yakın olası değer %d Hz (Uyarı, >5% hatası)." },
+ { "Compile successful; wrote IHEX for AVR to '%s'.\r\n\r\nRemember to set the processor configuration (fuses) correctly. This does not happen automatically.", "Derleme başarılı. AVR için derlenen '%s' IHEX dosyasına kaydedildi.\r\n\r\n MİB konfigürasyonunu ayarlamayı unutmayın. Bu işlem otomatik olarak yapılmamaktadır." },
+ { "( ) Normal", "( ) Normal" },
+ { "(/) Negated", "(/) Terslenmiş" },
+ { "(S) Set-Only", "(S) Set" },
+ { "(R) Reset-Only", "(R) Reset" },
+ { "Pin on MCU", "MİB Bacağı" },
+ { "Coil", "Bobin" },
+ { "Comment", "Açıklama" },
+ { "Cycle Time (ms):", "Çevrim Süresi (ms):" },
+ { "Crystal Frequency (MHz):", "Kristal Frekansı (MHz):" },
+ { "UART Baud Rate (bps):", "UART Baud Rate (bps):" },
+ { "Serial (UART) will use pins %d and %d.\r\n\r\n", "Seri iletişim için (UART) %d ve %d bacakları kullanılacaktır.\r\n\r\n" },
+ { "Please select a micro with a UART.\r\n\r\n", "Lütfen UART olan bir MİB seçiniz.\r\n\r\n" },
+ { "No serial instructions (UART Send/UART Receive) are in use; add one to program before setting baud rate.\r\n\r\n", "Seri iletişim komutu kullanmadınız. Hızı ayarlamadan önce komut kullanmalısınız.\r\n\r\n" },
+ { "The cycle time for the 'PLC' runtime generated by LDmicro is user-configurable. Very short cycle times may not be achievable due to processor speed constraints, and very long cycle times may not be achievable due to hardware overflows. Cycle times between 10 ms and 100 ms will usually be practical.\r\n\r\nThe compiler must know what speed crystal you are using with the micro to convert between timing in clock cycles and timing in seconds. A 4 MHz to 20 MHz crystal is typical; check the speed grade of the part you are using to determine the maximum allowable clock speed before choosing a crystal.", "PLC için LDMicro tarafından verilen çevrim süresi kullanıcı tarafından değiştirilebilir. Çok kısa süreler işlemcinin hızından kaynaklanan sebeplerden dolayı verilemeyebilir. 10ms ile 100ms arasındaki değerler çevrim süresi için genellikle uygun değerlerdir.\r\n\r\n.LDMicro kullanılan kristalin hızını bilmelidir. Bu değer program içerisinde kullanılır. Bilindiği üzere genellikle 4MHz ile 20MHz arasında değere sahip kristaller kullanılmaktadır. Kullandığınız kristalin değerini ayarlamalısınız." },
+ { "PLC Configuration", "PLC Ayarları" },
+ { "Zero cycle time not valid; resetting to 10 ms.", "Çevrim süresi sıfır olamaz. 10ms olarak değiştirildi." },
+ { "Source", "Kaynak" },
+ { "Internal Relay", "Dahili Röle" },
+ { "Input pin", "Giriş Bacağı" },
+ { "Output pin", "Çıkış Bacağı" },
+ { "|/| Negated", "|/| Terslenmiş" },
+ { "Contacts", "Kontak" },
+ { "No ADC or ADC not supported for selected micro.", "Bu işlemcide ADC yok yada ADC desteklenmiyor." },
+ { "Assign:", "Değeri:" },
+ { "No microcontroller has been selected. You must select a microcontroller before you can assign I/O pins.\r\n\r\nSelect a microcontroller under the Settings menu and try again.", "İşlemci seçmediniz.\r\n\r\n G/Ç uçlarını seçmeden önce Ayarlar menüsünden işlemci seçiniz." },
+ { "I/O Pin Assignment", "G/Ç Bacak Tanımı" },
+ { "Can't specify I/O assignment for ANSI C target; compile and see comments in generated source code.", "ANSI C hedef için G/Ç tanımlaması yapılamadı. Dosyayı derleyerek oluşturulan kaynak kodundaki yorumları inceleyiniz." },
+ { "Can't specify I/O assignment for interpretable target; see comments in reference implementation of interpreter.", "Hedef için G/Ç tanımı yapılamadı. Derleyicinin kullanım kitapçığını inceleyiniz." },
+ { "Can only assign pin number to input/output pins (Xname or Yname or Aname).", "Sadece giriş/çıkış uçları için bacak tanımlaması yapılabilir. (XName veya YName veya AName)." },
+ { "No ADC or ADC not supported for this micro.", "Bu işlemcide ADC yok yada ADC desteklenmiyor." },
+ { "Rename I/O from default name ('%s') before assigning MCU pin.", "('%s') öntanımlı isimdir. MİB bacağı tanımlamadan önce bu ismi değiştiriniz." },
+ { "I/O Pin", "G/Ç Bacakları" },
+ { "(no pin)", "(Bacak Yok)" },
+ { "<UART needs!>", "<UART gerekli!>" },
+ { "<PWM needs!>", "<PWM gerekli!>" },
+ { "<not an I/O!>", "<G/Ç değil>" },
+ { "Export As Text", "Yazı dosyası olarak ver" },
+ { "Couldn't write to '%s'.", "'%s' dosyasına yazılamadı." },
+ { "Compile To", "Derlenecek Yer" },
+ { "Must choose a target microcontroller before compiling.", "Derlemeden önce işlemci seçilmelidir." },
+ { "UART function used but not supported for this micro.", "Komut kullanmışsınız, ancak UART işlemleri bu işlemci için desteklenmiyor." },
+ { "PWM function used but not supported for this micro.", "Komut kullanmışsınız, ancak PWM işlemleri bu işlemci için desteklenmiyor." },
+ { "The program has changed since it was last saved.\r\n\r\nDo you want to save the changes?", "Dosyada değişiklik yaptınız.\r\n\r\n Kaydetmek ister misiniz?" },
+ { "--add comment here--", "--aciklamanizi buraya ekleyiniz--" },
+ { "Start new program?", "Yeni dosya oluşturulsun mu?" },
+ { "Couldn't open '%s'.", "'%s' dosyasına kayıt yapılamıyor." },
+ { "Name", "İsim" },
+ { "State", "Durum/Değer" },
+ { "Pin on Processor", "İşlemci Bacak No" },
+ { "MCU Port", "İşlemci Portu" },
+ { "LDmicro - Simulation (Running)", "LDmicro - Simülasyon (Çalışıyor)" },
+ { "LDmicro - Simulation (Stopped)", "LDmicro - Simülasyon (Durduruldu)" },
+ { "LDmicro - Program Editor", "LDmicro – Program Editörü " },
+ { " - (not yet saved)", " - (değişiklikler kaydedilmedi)" },
+ { "&New\tCtrl+N", "&Yeni Dosya\tCtrl+N" },
+ { "&Open...\tCtrl+O", "&Dosya Aç\tCtrl+O" },
+ { "&Save\tCtrl+S", "&Dosyayı Kaydet\tCtrl+S" },
+ { "Save &As...", "Dosyayı Farklı Kaydet" },
+ { "&Export As Text...\tCtrl+E", "&Metin Dosyası Olarak Kaydet\tCtrl+E" },
+ { "E&xit", "Çıkış" },
+ { "&Undo\tCtrl+Z", "Değişikliği Geri Al\tCtrl+Z" },
+ { "&Redo\tCtrl+Y", "&Değişikliği Tekrarla\tCtrl+Y" },
+ { "Insert Rung &Before\tShift+6", "Üst kısma satır (Rung) ekle\tShift+6" },
+ { "Insert Rung &After\tShift+V", "Alt kısma satır (Rung) ekle\tShift+V" },
+ { "Move Selected Rung &Up\tShift+Up", "Seçili satırı üste taşı\tShift+Up" },
+ { "Move Selected Rung &Down\tShift+Down", "Seçili satırı alta taşı\tShift+Down" },
+ { "&Delete Selected Element\tDel", "&Seçili Elemanı Sil\tDel" },
+ { "D&elete Rung\tShift+Del", "Seçili Satırı Sil\tShift+Del" },
+ { "Insert Co&mment\t;", "Açıklama Ekle\t;" },
+ { "Insert &Contacts\tC", "Kontak Eekle\tC" },
+ { "Insert OSR (One Shot Rising)\t&/", "OSR ekle (Yükselen Kenar)\t&/" },
+ { "Insert OSF (One Shot Falling)\t&\\", "OSF ekle (Düşen Kenar)\t&\\" },
+ { "Insert T&ON (Delayed Turn On)\tO", "T&ON ekle (Turn-On Gecikme)\tO" },
+ { "Insert TO&F (Delayed Turn Off)\tF", "T&OF ekle (Turn-Off Gecikme)\tF" },
+ { "Insert R&TO (Retentive Delayed Turn On)\tT", "R&TO ekle (Süre Sayan Turn-On Gecikme)\tT" },
+ { "Insert CT&U (Count Up)\tU", "CT&U ekle (Yukarı Sayıcı)\tU" },
+ { "Insert CT&D (Count Down)\tI", "CT&D ekle (Aşağı Sayıcı)\tI" },
+ { "Insert CT&C (Count Circular)\tJ", "CT&C ekle (Döngüsel Sayıcı)\tJ" },
+ { "Insert EQU (Compare for Equals)\t=", "EQU ekle (Eşitlik Kontrolü)\t=" },
+ { "Insert NEQ (Compare for Not Equals)", "NEQ ekle (Farklılık Kontrolü)" },
+ { "Insert GRT (Compare for Greater Than)\t>", "GRT ekle (Büyük Kontrolü)\t>" },
+ { "Insert GEQ (Compare for Greater Than or Equal)\t.", "GEQ ekle (Büyük yada Eşit Kontrolü)\t." },
+ { "Insert LES (Compare for Less Than)\t<", "LES ekle (Küçük Kontrolü)\t<" },
+ { "Insert LEQ (Compare for Less Than or Equal)\t,", "LEQ ekle (Küçük yada Eşit Kontrolü)\t," },
+ { "Insert Open-Circuit", "Açık Devre ekle" },
+ { "Insert Short-Circuit", "Kapalı Devre ekle" },
+ { "Insert Master Control Relay", "Ana Kontrol Rölesi ekle" },
+ { "Insert Coi&l\tL", "Bobin ek&le\tL" },
+ { "Insert R&ES (Counter/RTO Reset)\tE", "R&ES ekle (RTO/Sayıcı Sıfırlaması)\tE" },
+ { "Insert MOV (Move)\tM", "MOV (Taşı) ekle\tM" },
+ { "Insert ADD (16-bit Integer Add)\t+", "ADD (16 bit Toplama)ekle\t+" },
+ { "Insert SUB (16-bit Integer Subtract)\t-", "SUB (16 bit çıkarma) ekle\t-" },
+ { "Insert MUL (16-bit Integer Multiply)\t*", "MUL (16 bit çarpma) ekle\t*" },
+ { "Insert DIV (16-bit Integer Divide)\tD", "DIV (16 bit bölme) ekle\tD" },
+ { "Insert Shift Register", "Shift Register ekle" },
+ { "Insert Look-Up Table", "Değer Tablosu ekle" },
+ { "Insert Piecewise Linear", "Parçalı Lineer ekle" },
+ { "Insert Formatted String Over UART", "UART Üzerinden Biçimlendirilmiş Kelime Ekle" },
+ { "Insert &UART Send", "&UART'dan Gönderme ekle" },
+ { "Insert &UART Receive", "&UART'dan Alma ekle" },
+ { "Insert Set PWM Output", "PWM Çıkışı Akit Et ekle" },
+ { "Insert A/D Converter Read\tP", "A/D Çeviriciden Oku ekle\tP" },
+ { "Insert Make Persistent", "EPROM'da Sakla ekle" },
+ { "Make Norm&al\tA", "Normale Çevir\tA" },
+ { "Make &Negated\tN", "Terslenmiş Yap\tN" },
+ { "Make &Set-Only\tS", "Set Yap\tS" },
+ { "Make &Reset-Only\tR", "Reset Yap\tR" },
+ { "&MCU Parameters...", "&İşlemci Ayarları..." },
+ { "(no microcontroller)", "(işlemci yok)" },
+ { "&Microcontroller", "İşlemci Seçimi" },
+ { "Si&mulation Mode\tCtrl+M", "Si&mülasyon Modu\tCtrl+M" },
+ { "Start &Real-Time Simulation\tCtrl+R", "Ge&rçek Zamanlı Simülasyonu Başlat\tCtrl+R" },
+ { "&Halt Simulation\tCtrl+H", "Simülasyonu Durdur\tCtrl+H" },
+ { "Single &Cycle\tSpace", "Satır Satır Simülasyon\tEspace" },
+ { "&Compile\tF5", "&Derle\tF5" },
+ { "Compile &As...", "Farklı Derle..." },
+ { "&Manual...\tF1", "&Kitapçık...\tF1" },
+ { "&About...", "&Bilgi..." },
+ { "&File", "&Dosya" },
+ { "&Edit", "&Düzen" },
+ { "&Settings", "&Ayarlar" },
+ { "&Instruction", "K&omutlar" },
+ { "Si&mulate", "Si&mülasyon" },
+ { "&Compile", "&Derle" },
+ { "&Help", "&Yardım" },
+ { "no MCU selected", "İşlemci Seçilmedi" },
+ { "cycle time %.2f ms", "çevrim süresi %.2f ms" },
+ { "processor clock %.4f MHz", "işlemci frekansı %.4f MHz" },
+ { "Internal error relating to PIC paging; make program smaller or reshuffle it.", "PIC sayfalaması ile ilgili dahili hata oluştu. Programı kısaltınız yada değiştiriniz." },
+ { "PWM frequency too fast.", "PWM frekansı çok hızlı." },
+ { "PWM frequency too slow.", "PWM frekansı çok yavaş." },
+ { "Cycle time too fast; increase cycle time, or use faster crystal.", "Çevrim süresi çok kısa. Süreyi yada kristal frekansını artırınız." },
+ { "Cycle time too slow; decrease cycle time, or use slower crystal.", "Çevrim süresi çok uzun. Süreyi yada kristal frekansını azaltınız.." },
+ { "Couldn't open file '%s'", "'%s' dosyası açılamadı." },
+ { "Zero baud rate not possible.", "İletişim hızı (Baudrate) sıfır olamaz." },
+ { "Compile successful; wrote IHEX for PIC16 to '%s'.\r\n\r\nConfiguration word (fuses) has been set for crystal oscillator, BOD enabled, LVP disabled, PWRT enabled, all code protection off.\r\n\r\nUsed %d/%d words of program flash (chip %d%% full).", "Derleme başarıyla yapıldı; PIC16 için IHEX dosyası '%s' dosyasına kaydedildi.\r\n\r\nAyarlar: (PIC konfigürasyonu) kristal osilatör, BOD aktif, LVP pasif, PWRT aktif, tüm kod koruması kapalı.\r\n\r\nPIC hafızasının %d/%d kelimesi kullanıldı. (Hafıza %d%% dolu)." },
+ { "Type", "Tipi" },
+ { "Timer", "Zamanlayıcı" },
+ { "Counter", "Sayıcı" },
+ { "Reset", "Reset" },
+ { "OK", "Tamam" },
+ { "Cancel", "Vazgeç" },
+ { "Empty textbox; not permitted.", "Yazı kutusu boş olamaz" },
+ { "Bad use of quotes: <%s>", "Tırnaklar yanlış kullanılmış: <%s>" },
+ { "Turn-On Delay", "Turn-On Gecikme Devresi" },
+ { "Turn-Off Delay", "Turn-Off Gecikme Devresi" },
+ { "Retentive Turn-On Delay", "Değeri Saklanan Turn-On Gecikme" },
+ { "Delay (ms):", "Gecikme (ms):" },
+ { "Delay too long; maximum is 2**31 us.", "Gecikme çok fazla. En fazla 2**31 us olabilir." },
+ { "Delay cannot be zero or negative.", "Gecikme sıfır yada eksi değer olamaz." },
+ { "Count Up", "Yukarı Say" },
+ { "Count Down", "Aşağı Say" },
+ { "Circular Counter", "Dairesel Sayıcı" },
+ { "Max value:", "En Yüksek Değer:" },
+ { "True if >= :", "Doğru Eğer >= :" },
+ { "If Equals", "Eşitse" },
+ { "If Not Equals", "Eşit Değilse" },
+ { "If Greater Than", "Büyükse" },
+ { "If Greater Than or Equal To", "Büyük yada Eşitse" },
+ { "If Less Than", "Küçükse" },
+ { "If Less Than or Equal To", "Küçük yada Eşitse" },
+ { "'Closed' if:", "'Kapalı' Eğer:" },
+ { "Move", "Taşı" },
+ { "Read A/D Converter", "A/D Çeviriciyi Oku" },
+ { "Duty cycle var:", "Pals Genişliği Değeri:" },
+ { "Frequency (Hz):", "Frekans (Hz):" },
+ { "Set PWM Duty Cycle", "PWM Pals Genişliği Değeri" },
+ { "Source:", "Kaynak:" },
+ { "Receive from UART", "UART'dan bilgi al" },
+ { "Send to UART", "UART'dan bilgi gönder" },
+ { "Add", "Topla" },
+ { "Subtract", "Çıkar" },
+ { "Multiply", "Çarp" },
+ { "Divide", "Böl" },
+ { "Destination:", "Hedef:" },
+ { "is set := :", "Verilen Değer := :" },
+ { "Name:", "İsim:" },
+ { "Stages:", "Aşamalar:" },
+ { "Shift Register", "Shift Register" },
+ { "Not a reasonable size for a shift register.", "Shift Register için kabul edilebilir değer değil." },
+ { "String:", "Karakter Dizisi:" },
+ { "Formatted String Over UART", "UART Üzerinden Biçimlendirilmiş Karakter Dizisi" },
+ { "Variable:", "Değişken:" },
+ { "Make Persistent", "EEPROM'da Sakla" },
+ { "Too many elements in subcircuit!", "Alt devrede çok fazla eleman var!" },
+ { "Too many rungs!", "Satır sayısı (Rung) fazla!" },
+ { "Error", "Hata" },
+ { "ANSI C target does not support peripherals (UART, PWM, ADC, EEPROM). Skipping that instruction.", "ANSI C hedef özellikleri desteklemiyor.(UART, ADC, EEPROM). İlgili komutlar işlenmeyecek." },
+ { "Compile successful; wrote C source code to '%s'.\r\n\r\nThis is not a complete C program. You have to provide the runtime and all the I/O routines. See the comments in the source code for information about how to do this.", "Derleme başarıyla tamamlandı. C kaynak kodu '%s' dosyasına yazıldı.\r\n\r\nBu dosya tam bir C dosyası değildir. G/Ç rutinlerini kendiniz sağlamalısınız. Dosyayı incelemeniz faydalı olacaktır." },
+ { "Cannot delete rung; program must have at least one rung.", "Bu satır silinemez. Programda en az bir tane satır (Rung) olmalıdır." },
+ { "Out of memory; simplify program or choose microcontroller with more memory.", "İŞlemci hafızası doldu; Programı kısaltınız yada daha yüksek hafızası olan bir işlemci seçiniz." },
+ { "Must assign pins for all ADC inputs (name '%s').", "Tüm ADC girişlerinin bacakları belirtilmelidir (ADC '%s')." },
+ { "Internal limit exceeded (number of vars)", "Dahili sınır aşıldı (Değişken Sayısı)" },
+ { "Internal relay '%s' never assigned; add its coil somewhere.", "'%s' dahili rölesine değer verilmedi, Bu röle için bir bobin ekleyiniz." },
+ { "Must assign pins for all I/O.\r\n\r\n'%s' is not assigned.", "Tüm G/Ç uçları için bacaklar belirtilmelidir.\r\n\r\n'%s' ucuna değer verilmemiş." },
+ { "UART in use; pins %d and %d reserved for that.", "UART Kullanımda; %d ve %d bacakları bunun için kullanılmaktadır. Siz kullanamazsınız." },
+ { "PWM in use; pin %d reserved for that.", "PWM Kullanımda; %d bacağı bunun için ayrılmıştır. Siz kullanamazsınız.." },
+ { "UART baud rate generator: divisor=%d actual=%.4f for %.2f%% error.\r\n\r\nThis is too large; try a different baud rate (slower probably), or a crystal frequency chosen to be divisible by many common baud rates (e.g. 3.6864 MHz, 14.7456 MHz).\r\n\r\nCode will be generated anyways but serial may be unreliable or completely broken.", "UART Hız Hesaplayıcısı: Bölen=%d Gerçekte=%.4f (%.2f%% hata payı ile).\r\n\r\nBu değer çok yüksektir. Değişik bir değer denemelisiniz yada kristal frekansını sık kullanılan ve bu değerlere bölünebilen bir değer seçiniz. (Mesela 3.6864MHz, 14.7456MHz gibi).\r\n\r\nHer durumda kod oluşturulacaktır; ancak seri iletişim düzgün çalışmayabilir yada tamamen durabilir." },
+ { "UART baud rate generator: too slow, divisor overflows. Use a slower crystal or a faster baud rate.\r\n\r\nCode will be generated anyways but serial will likely be completely broken.", "UART Hız Hesaplayıcısı: Hız çok düşük. Bu nedenle bölen taşma yapıyor. Ya kristal frekansını düşürünüz yada hızı (baudrate) artırınız.\r\n\r\nHer durumda kod oluşturulacaktır; ancak seri iletişim düzgün çalışmayabilir yada tamamen durabilir." },
+ { "Couldn't open '%s'\n", "'%s' dosyası açılamadı\n" },
+ { "Timer period too short (needs faster cycle time).", "Zamanlayıcı peryodu çok kısa (daha yüksek çevrim süresi gerekli)." },
+ { "Timer period too long (max 32767 times cycle time); use a slower cycle time.", "Zamanlayıcı peryodu çok kısa(en fazla. çevrim süresinin 32767 katı olabilir); çevrim süresini düşürünüz." },
+ { "Constant %d out of range: -32768 to 32767 inclusive.", "%d sabiti aralığın dışında: -32768 ile 32767 arasında olmalıdır." },
+ { "Move instruction: '%s' not a valid destination.", "Taşıma Komutu: '%s' geçerli bir hedef adresi değil." },
+ { "Math instruction: '%s' not a valid destination.", "Matematik Komutu: '%s'geçerli bir hedef adresi değil." },
+ { "Piecewise linear lookup table with zero elements!", "Parçalı doğrusal arama tablosunda değer yok!" },
+ { "x values in piecewise linear table must be strictly increasing.", "Parçalı doğrusal arama tablosundaki x değerleri artan sıralamalı olmalı." },
+ { "Numerical problem with piecewise linear lookup table. Either make the table entries smaller, or space the points together more closely.\r\n\r\nSee the help file for details.", "Parçalı doğrusal arama tablosunda sayısal hata.\r\n\r\nDetaylar için yardım menüsünü inceleyiniz." },
+ { "Multiple escapes (\\0-9) present in format string, not allowed.", "Biçimli karakter dizisinde birden çok escape kodu var(\\0-9)." },
+ { "Bad escape: correct form is \\xAB.", "Yanlış ESC komutu: doğru şekil = \\xAB." },
+ { "Bad escape '\\%c'", "Yanlış ESC komutu '\\%c'" },
+ { "Variable is interpolated into formatted string, but none is specified.", "Biçimlendirilmiş karakter kümesine değişken tanımlanmış ama hiç belirtilmemiş." },
+ { "No variable is interpolated into formatted string, but a variable name is specified. Include a string like '\\-3', or leave variable name blank.", "Biçimlendirilmiş karakter kümesine değişken atanmamış ama değişken ismi belirtilmiş. Ya değişken ismini belirtiniz yada '\\-3' gibi bir değer veriniz.." },
+ { "Empty row; delete it or add instructions before compiling.", "Satır boş; Satırı silmeli yada komut eklemelisiniz." },
+ { "Couldn't write to '%s'", "'%s' dosyasına kayıt yapılamıyor." },
+ { "Unsupported op (anything ADC, PWM, UART, EEPROM) for interpretable target.", "Komut desteklenmiyor. (ADC, PWM, UART, EEPROM ile ilgili komutlardan herhangi biri)" },
+ { "Compile successful; wrote interpretable code to '%s'.\r\n\r\nYou probably have to adapt the interpreter to your application. See the documentation.", "Derleme başarıyla tamamlandı. Kod '%s' dosyasına yazıldı.\r\n\r\nDerleyiciyi uygulamanıza göre değiştirmeniz gerekebilir. Geniş bilgi için LDMicro belgelerine başvurabilirsiniz." },
+ { "Microcontroller '%s' not supported.\r\n\r\nDefaulting to no selected MCU.", "'%s' desteklenen bir işlemci değil.\r\n\r\nİşlemci ayarı işlemci yok şeklinde değiştirilmiştir." },
+ { "File format error; perhaps this program is for a newer version of LDmicro?", "Dosya biçimi hatası. Açmaya çalıştığınız dosya ya LDMicro dosyası değil yada yeni bir sürüm ile yazılmış." },
+ { "Index:", "Liste:" },
+ { "Points:", "Değer Sayısı:" },
+ { "Count:", "Adet:" },
+ { "Edit table of ASCII values like a string", "ASCII değer tablosunu karakter dizisi gibi düzenle." },
+ { "Look-Up Table", "Arama Tablosu" },
+ { "Piecewise Linear Table", "Parçalı Lineer Tablo" },
+ { "LDmicro Error", "LDmicro Hatası" },
+ { "Compile Successful", "Derleme Başarılı" },
+ { "digital in", "Dijital Giriş" },
+ { "digital out", "Dijital Çıkış" },
+ { "int. relay", "Dahili Röle" },
+ { "UART tx", "UART tx" },
+ { "UART rx", "UART rx" },
+ { "PWM out", "PWM Çıkışı" },
+ { "turn-on delay", "Turn-On Gecikme" },
+ { "turn-off delay", "Turn-Off Gecikme" },
+ { "retentive timer", "değeri saklanan zamanlayıcı" },
+ { "counter", "Sayıcı" },
+ { "general var", "Genel Değişken" },
+ { "adc input", "ADC Girişi" },
+ { "<corrupt!>", "<bozuk>" },
+ { "(not assigned)", "(tanımlı değil)" },
+ { "<no UART!>", "<UART Yok!>" },
+ { "<no PWM!>", "<PWM Yok!>" },
+ { "TOF: variable cannot be used elsewhere", "TOF: Değişken başka bir yerde kullanılamaz" },
+ { "TON: variable cannot be used elsewhere", "TON: Değişken başka bir yerde kullanılamaz" },
+ { "RTO: variable can only be used for RES elsewhere", "RTO: Değişken sadece RES için kullanılabilir" },
+ { "Variable '%s' not assigned to, e.g. with a MOV statement, an ADD statement, etc.\r\n\r\nThis is probably a programming error; now it will always be zero.", "'%s' değer atanmamış.Örneğin, MOV, ADD komutları ile değer atanabilir.\r\n\r\nMuhtemelen bu bir programlama hatasıdır. Bu nedenle değişkenin değeri 0 olarak kullanılacaktır." },
+ { "Variable for '%s' incorrectly assigned: %s.", "'%s' için değişken hatalı atanmış: %s." },
+ { "Division by zero; halting simulation", "Sıfıra bölüm; Simülasyon durduruldu." },
+ { "!!!too long!!!", "!!!çok uzun!!" },
+ { "\n\nI/O ASSIGNMENT:\n\n", "\n\nG/Ç TANIMI:\n\n" },
+ { " Name | Type | Pin\n", " İsim | Tipi | Bacak\n" },
+};
+static Lang LangTr = {
+ LangTrTable, sizeof(LangTrTable)/sizeof(LangTrTable[0])
+};
+#endif
diff --git a/ldmicro/pic16.cpp b/ldmicro/pic16.cpp index ae815fe..a813420 100644 --- a/ldmicro/pic16.cpp +++ b/ldmicro/pic16.cpp @@ -22,7 +22,7 @@ // runtime needed to schedule the cycles. // Jonathan Westhues, Oct 2004 //----------------------------------------------------------------------------- -#include <windows.h> +#include "linuxUI.h" #include <math.h> #include <stdio.h> #include <setjmp.h> diff --git a/ldmicro/resetdialog.cpp b/ldmicro/resetdialog.cpp index 00421d5..b83cd42 100644 --- a/ldmicro/resetdialog.cpp +++ b/ldmicro/resetdialog.cpp @@ -21,9 +21,9 @@ // which can be that of either a timer or a counter. // Jonathan Westhues, Nov 2004 //----------------------------------------------------------------------------- -#include <windows.h> +#include "linuxUI.h" #include <stdio.h> -#include <commctrl.h> +//#include <commctrl.h> #include "ldmicro.h" diff --git a/ldmicro/schematic.cpp b/ldmicro/schematic.cpp index 84be7b6..849093e 100644 --- a/ldmicro/schematic.cpp +++ b/ldmicro/schematic.cpp @@ -21,7 +21,7 @@ // Actual manipulation of circuit elements happens in circuit.cpp, though. // Jonathan Westhues, Oct 2004 //----------------------------------------------------------------------------- -#include <windows.h> +#include "linuxUI.h" #include <stdio.h> #include <stdlib.h> @@ -83,43 +83,43 @@ BOOL FindSelected(int *gx, int *gy) //----------------------------------------------------------------------------- void SelectElement(int gx, int gy, int state) { - if(gx < 0 || gy < 0) { - if(!FindSelected(&gx, &gy)) { - return; - } - } - - if(Selected) Selected->selectedState = SELECTED_NONE; - - Selected = DisplayMatrix[gx][gy]; - SelectedWhich = DisplayMatrixWhich[gx][gy]; - - if(SelectedWhich == ELEM_PLACEHOLDER) { - state = SELECTED_LEFT; - } - - if((gy - ScrollYOffset) >= ScreenRowsAvailable()) { - ScrollYOffset = gy - ScreenRowsAvailable() + 1; - RefreshScrollbars(); - } - if((gy - ScrollYOffset) < 0) { - ScrollYOffset = gy; - RefreshScrollbars(); - } - if((gx - ScrollXOffset*POS_WIDTH*FONT_WIDTH) >= ScreenColsAvailable()) { - ScrollXOffset = gx*POS_WIDTH*FONT_WIDTH - ScreenColsAvailable(); - RefreshScrollbars(); - } - if((gx - ScrollXOffset*POS_WIDTH*FONT_WIDTH) < 0) { - ScrollXOffset = gx*POS_WIDTH*FONT_WIDTH; - RefreshScrollbars(); - } - - ok(); - Selected->selectedState = state; - ok(); - - WhatCanWeDoFromCursorAndTopology(); +// if(gx < 0 || gy < 0) { +// if(!FindSelected(&gx, &gy)) { +// return; +// } +// } + +// if(Selected) Selected->selectedState = SELECTED_NONE; + +// Selected = DisplayMatrix[gx][gy]; +// SelectedWhich = DisplayMatrixWhich[gx][gy]; + +// if(SelectedWhich == ELEM_PLACEHOLDER) { +// state = SELECTED_LEFT; +// } + +// if((gy - ScrollYOffset) >= ScreenRowsAvailable()) { +// ScrollYOffset = gy - ScreenRowsAvailable() + 1; +// RefreshScrollbars(); +// } +// if((gy - ScrollYOffset) < 0) { +// ScrollYOffset = gy; +// RefreshScrollbars(); +// } +// if((gx - ScrollXOffset*POS_WIDTH*FONT_WIDTH) >= ScreenColsAvailable()) { +// ScrollXOffset = gx*POS_WIDTH*FONT_WIDTH - ScreenColsAvailable(); +// RefreshScrollbars(); +// } +// if((gx - ScrollXOffset*POS_WIDTH*FONT_WIDTH) < 0) { +// ScrollXOffset = gx*POS_WIDTH*FONT_WIDTH; +// RefreshScrollbars(); +// } + +// ok(); +// Selected->selectedState = state; +// ok(); + +// WhatCanWeDoFromCursorAndTopology(); } //----------------------------------------------------------------------------- @@ -129,86 +129,86 @@ void SelectElement(int gx, int gy, int state) //----------------------------------------------------------------------------- void WhatCanWeDoFromCursorAndTopology(void) { - BOOL canNegate = FALSE, canNormal = FALSE; - BOOL canResetOnly = FALSE, canSetOnly = FALSE; - BOOL canPushUp = TRUE, canPushDown = TRUE; - - BOOL canDelete = TRUE; - - int i = RungContainingSelected(); - if(i >= 0) { - if(i == 0) canPushUp = FALSE; - if(i == (Prog.numRungs-1)) canPushDown = FALSE; - - if(Prog.rungs[i]->count == 1 && - Prog.rungs[i]->contents[0].which == ELEM_PLACEHOLDER) - { - canDelete = FALSE; - } - } - - CanInsertEnd = FALSE; - CanInsertOther = TRUE; - - if(Selected && - (SelectedWhich == ELEM_COIL || - SelectedWhich == ELEM_RES || - SelectedWhich == ELEM_ADD || - SelectedWhich == ELEM_SUB || - SelectedWhich == ELEM_MUL || - SelectedWhich == ELEM_DIV || - SelectedWhich == ELEM_CTC || - SelectedWhich == ELEM_READ_ADC || - SelectedWhich == ELEM_SET_PWM || - SelectedWhich == ELEM_MASTER_RELAY || - SelectedWhich == ELEM_SHIFT_REGISTER || - SelectedWhich == ELEM_LOOK_UP_TABLE || - SelectedWhich == ELEM_PIECEWISE_LINEAR || - SelectedWhich == ELEM_PERSIST || - SelectedWhich == ELEM_MOVE)) - { - if(SelectedWhich == ELEM_COIL) { - canNegate = TRUE; - canNormal = TRUE; - canResetOnly = TRUE; - canSetOnly = TRUE; - } - - if(Selected->selectedState == SELECTED_ABOVE || - Selected->selectedState == SELECTED_BELOW) - { - CanInsertEnd = TRUE; - CanInsertOther = FALSE; - } else if(Selected->selectedState == SELECTED_RIGHT) { - CanInsertEnd = FALSE; - CanInsertOther = FALSE; - } - } else if(Selected) { - if(Selected->selectedState == SELECTED_RIGHT || - SelectedWhich == ELEM_PLACEHOLDER) - { - CanInsertEnd = ItemIsLastInCircuit(Selected); - } - } - if(SelectedWhich == ELEM_CONTACTS) { - canNegate = TRUE; - canNormal = TRUE; - } - if(SelectedWhich == ELEM_PLACEHOLDER) { - // a comment must be the only element in its rung, and it will fill - // the rung entirely - CanInsertComment = TRUE; - } else { - CanInsertComment = FALSE; - } - if(SelectedWhich == ELEM_COMMENT) { - // if there's a comment there already then don't let anything else - // into the rung - CanInsertEnd = FALSE; - CanInsertOther = FALSE; - } - SetMenusEnabled(canNegate, canNormal, canResetOnly, canSetOnly, canDelete, - CanInsertEnd, CanInsertOther, canPushDown, canPushUp, CanInsertComment); +// BOOL canNegate = FALSE, canNormal = FALSE; +// BOOL canResetOnly = FALSE, canSetOnly = FALSE; +// BOOL canPushUp = TRUE, canPushDown = TRUE; + +// BOOL canDelete = TRUE; + +// int i = RungContainingSelected(); +// if(i >= 0) { +// if(i == 0) canPushUp = FALSE; +// if(i == (Prog.numRungs-1)) canPushDown = FALSE; + +// if(Prog.rungs[i]->count == 1 && +// Prog.rungs[i]->contents[0].which == ELEM_PLACEHOLDER) +// { +// canDelete = FALSE; +// } +// } + +// CanInsertEnd = FALSE; +// CanInsertOther = TRUE; + +// if(Selected && +// (SelectedWhich == ELEM_COIL || +// SelectedWhich == ELEM_RES || +// SelectedWhich == ELEM_ADD || +// SelectedWhich == ELEM_SUB || +// SelectedWhich == ELEM_MUL || +// SelectedWhich == ELEM_DIV || +// SelectedWhich == ELEM_CTC || +// SelectedWhich == ELEM_READ_ADC || +// SelectedWhich == ELEM_SET_PWM || +// SelectedWhich == ELEM_MASTER_RELAY || +// SelectedWhich == ELEM_SHIFT_REGISTER || +// SelectedWhich == ELEM_LOOK_UP_TABLE || +// SelectedWhich == ELEM_PIECEWISE_LINEAR || +// SelectedWhich == ELEM_PERSIST || +// SelectedWhich == ELEM_MOVE)) +// { +// if(SelectedWhich == ELEM_COIL) { +// canNegate = TRUE; +// canNormal = TRUE; +// canResetOnly = TRUE; +// canSetOnly = TRUE; +// } + +// if(Selected->selectedState == SELECTED_ABOVE || +// Selected->selectedState == SELECTED_BELOW) +// { +// CanInsertEnd = TRUE; +// CanInsertOther = FALSE; +// } else if(Selected->selectedState == SELECTED_RIGHT) { +// CanInsertEnd = FALSE; +// CanInsertOther = FALSE; +// } +// } else if(Selected) { +// if(Selected->selectedState == SELECTED_RIGHT || +// SelectedWhich == ELEM_PLACEHOLDER) +// { +// CanInsertEnd = ItemIsLastInCircuit(Selected); +// } +// } +// if(SelectedWhich == ELEM_CONTACTS) { +// canNegate = TRUE; +// canNormal = TRUE; +// } +// if(SelectedWhich == ELEM_PLACEHOLDER) { +// // a comment must be the only element in its rung, and it will fill +// // the rung entirely +// CanInsertComment = TRUE; +// } else { +// CanInsertComment = FALSE; +// } +// if(SelectedWhich == ELEM_COMMENT) { +// // if there's a comment there already then don't let anything else +// // into the rung +// CanInsertEnd = FALSE; +// CanInsertOther = FALSE; +// } +// SetMenusEnabled(canNegate, canNormal, canResetOnly, canSetOnly, canDelete, +// CanInsertEnd, CanInsertOther, canPushDown, canPushUp, CanInsertComment); } //----------------------------------------------------------------------------- @@ -250,33 +250,33 @@ void ForgetEverything(void) //----------------------------------------------------------------------------- BOOL MoveCursorTopLeft(void) { - int i, j; - // Let us first try to place it somewhere on-screen, so start at the - // vertical scroll offset, not the very top (to avoid placing the - // cursor in a position that would force us to scroll to put it in to - // view.) - for(i = 0; i < DISPLAY_MATRIX_X_SIZE; i++) { - for(j = ScrollYOffset; - j < DISPLAY_MATRIX_Y_SIZE && j < (ScrollYOffset+16); j++) - { - if(VALID_LEAF(DisplayMatrix[i][j])) { - SelectElement(i, j, SELECTED_LEFT); - return TRUE; - } - } - } - - // If that didn't work, then try anywhere on the diagram before giving - // up entirely. - for(i = 0; i < DISPLAY_MATRIX_X_SIZE; i++) { - for(j = 0; j < 16; j++) { - if(VALID_LEAF(DisplayMatrix[i][j])) { - SelectElement(i, j, SELECTED_LEFT); - return TRUE; - } - } - } - return FALSE; +// int i, j; +// // Let us first try to place it somewhere on-screen, so start at the +// // vertical scroll offset, not the very top (to avoid placing the +// // cursor in a position that would force us to scroll to put it in to +// // view.) +// for(i = 0; i < DISPLAY_MATRIX_X_SIZE; i++) { +// for(j = ScrollYOffset; +// j < DISPLAY_MATRIX_Y_SIZE && j < (ScrollYOffset+16); j++) +// { +// if(VALID_LEAF(DisplayMatrix[i][j])) { +// SelectElement(i, j, SELECTED_LEFT); +// return TRUE; +// } +// } +// } + +// // If that didn't work, then try anywhere on the diagram before giving +// // up entirely. +// for(i = 0; i < DISPLAY_MATRIX_X_SIZE; i++) { +// for(j = 0; j < 16; j++) { +// if(VALID_LEAF(DisplayMatrix[i][j])) { +// SelectElement(i, j, SELECTED_LEFT); +// return TRUE; +// } +// } +// } +// return FALSE; } //----------------------------------------------------------------------------- @@ -287,108 +287,108 @@ BOOL MoveCursorTopLeft(void) //----------------------------------------------------------------------------- void MoveCursorKeyboard(int keyCode) { - if(!Selected || Selected->selectedState == SELECTED_NONE) { - MoveCursorTopLeft(); - return; - } - - switch(keyCode) { - case VK_LEFT: { - if(!Selected || Selected->selectedState == SELECTED_NONE) { - break; - } - if(Selected->selectedState != SELECTED_LEFT) { - SelectElement(-1, -1, SELECTED_LEFT); - break; - } - if(SelectedWhich == ELEM_COMMENT) break; - int i, j; - if(FindSelected(&i, &j)) { - i--; - while(i >= 0 && (!VALID_LEAF(DisplayMatrix[i][j]) || - (DisplayMatrix[i][j] == Selected))) - { - i--; - } - if(i >= 0) { - SelectElement(i, j, SELECTED_RIGHT); - } - } - break; - } - case VK_RIGHT: { - if(!Selected || Selected->selectedState == SELECTED_NONE) { - break; - } - if(Selected->selectedState != SELECTED_RIGHT) { - SelectElement(-1, -1, SELECTED_RIGHT); - break; - } - if(SelectedWhich == ELEM_COMMENT) break; - int i, j; - if(FindSelected(&i, &j)) { - i++; - while(i < DISPLAY_MATRIX_X_SIZE && - !VALID_LEAF(DisplayMatrix[i][j])) - { - i++; - } - if(i != DISPLAY_MATRIX_X_SIZE) { - SelectElement(i, j, SELECTED_LEFT); - } - } - break; - } - case VK_UP: { - if(!Selected || Selected->selectedState == SELECTED_NONE) { - break; - } - if(Selected->selectedState != SELECTED_ABOVE && - SelectedWhich != ELEM_PLACEHOLDER) - { - SelectElement(-1, -1, SELECTED_ABOVE); - break; - } - int i, j; - if(FindSelected(&i, &j)) { - j--; - while(j >= 0 && !VALID_LEAF(DisplayMatrix[i][j])) - j--; - if(j >= 0) { - SelectElement(i, j, SELECTED_BELOW); - } - } - break; - } - case VK_DOWN: { - if(!Selected || Selected->selectedState == SELECTED_NONE) { - break; - } - if(Selected->selectedState != SELECTED_BELOW && - SelectedWhich != ELEM_PLACEHOLDER) - { - SelectElement(-1, -1, SELECTED_BELOW); - break; - } - int i, j; - if(FindSelected(&i, &j)) { - j++; - while(j < DISPLAY_MATRIX_Y_SIZE && - !VALID_LEAF(DisplayMatrix[i][j])) - { - j++; - } - if(j != DISPLAY_MATRIX_Y_SIZE) { - SelectElement(i, j, SELECTED_ABOVE); - } else if(ScrollYOffsetMax - ScrollYOffset < 3) { - // special case: scroll the end marker into view - ScrollYOffset = ScrollYOffsetMax; - RefreshScrollbars(); - } - } - break; - } - } +// if(!Selected || Selected->selectedState == SELECTED_NONE) { +// MoveCursorTopLeft(); +// return; +// } + +// switch(keyCode) { +// case VK_LEFT: { +// if(!Selected || Selected->selectedState == SELECTED_NONE) { +// break; +// } +// if(Selected->selectedState != SELECTED_LEFT) { +// SelectElement(-1, -1, SELECTED_LEFT); +// break; +// } +// if(SelectedWhich == ELEM_COMMENT) break; +// int i, j; +// if(FindSelected(&i, &j)) { +// i--; +// while(i >= 0 && (!VALID_LEAF(DisplayMatrix[i][j]) || +// (DisplayMatrix[i][j] == Selected))) +// { +// i--; +// } +// if(i >= 0) { +// SelectElement(i, j, SELECTED_RIGHT); +// } +// } +// break; +// } +// case VK_RIGHT: { +// if(!Selected || Selected->selectedState == SELECTED_NONE) { +// break; +// } +// if(Selected->selectedState != SELECTED_RIGHT) { +// SelectElement(-1, -1, SELECTED_RIGHT); +// break; +// } +// if(SelectedWhich == ELEM_COMMENT) break; +// int i, j; +// if(FindSelected(&i, &j)) { +// i++; +// while(i < DISPLAY_MATRIX_X_SIZE && +// !VALID_LEAF(DisplayMatrix[i][j])) +// { +// i++; +// } +// if(i != DISPLAY_MATRIX_X_SIZE) { +// SelectElement(i, j, SELECTED_LEFT); +// } +// } +// break; +// } +// case VK_UP: { +// if(!Selected || Selected->selectedState == SELECTED_NONE) { +// break; +// } +// if(Selected->selectedState != SELECTED_ABOVE && +// SelectedWhich != ELEM_PLACEHOLDER) +// { +// SelectElement(-1, -1, SELECTED_ABOVE); +// break; +// } +// int i, j; +// if(FindSelected(&i, &j)) { +// j--; +// while(j >= 0 && !VALID_LEAF(DisplayMatrix[i][j])) +// j--; +// if(j >= 0) { +// SelectElement(i, j, SELECTED_BELOW); +// } +// } +// break; +// } +// case VK_DOWN: { +// if(!Selected || Selected->selectedState == SELECTED_NONE) { +// break; +// } +// if(Selected->selectedState != SELECTED_BELOW && +// SelectedWhich != ELEM_PLACEHOLDER) +// { +// SelectElement(-1, -1, SELECTED_BELOW); +// break; +// } +// int i, j; +// if(FindSelected(&i, &j)) { +// j++; +// while(j < DISPLAY_MATRIX_Y_SIZE && +// !VALID_LEAF(DisplayMatrix[i][j])) +// { +// j++; +// } +// if(j != DISPLAY_MATRIX_Y_SIZE) { +// SelectElement(i, j, SELECTED_ABOVE); +// } else if(ScrollYOffsetMax - ScrollYOffset < 3) { +// // special case: scroll the end marker into view +// ScrollYOffset = ScrollYOffsetMax; +// RefreshScrollbars(); +// } +// } +// break; +// } +// } } //----------------------------------------------------------------------------- @@ -397,100 +397,100 @@ void MoveCursorKeyboard(int keyCode) //----------------------------------------------------------------------------- void EditSelectedElement(void) { - if(!Selected || Selected->selectedState == SELECTED_NONE) return; - - switch(SelectedWhich) { - case ELEM_COMMENT: - ShowCommentDialog(Selected->d.comment.str); - break; - - case ELEM_CONTACTS: - ShowContactsDialog(&(Selected->d.contacts.negated), - Selected->d.contacts.name); - break; - - case ELEM_COIL: - ShowCoilDialog(&(Selected->d.coil.negated), - &(Selected->d.coil.setOnly), &(Selected->d.coil.resetOnly), - Selected->d.coil.name); - break; - - case ELEM_TON: - case ELEM_TOF: - case ELEM_RTO: - ShowTimerDialog(SelectedWhich, &(Selected->d.timer.delay), - Selected->d.timer.name); - break; - - case ELEM_CTU: - case ELEM_CTD: - case ELEM_CTC: - ShowCounterDialog(SelectedWhich, &(Selected->d.counter.max), - Selected->d.counter.name); - break; - - case ELEM_EQU: - case ELEM_NEQ: - case ELEM_GRT: - case ELEM_GEQ: - case ELEM_LES: - case ELEM_LEQ: - ShowCmpDialog(SelectedWhich, Selected->d.cmp.op1, - Selected->d.cmp.op2); - break; - - case ELEM_ADD: - case ELEM_SUB: - case ELEM_MUL: - case ELEM_DIV: - ShowMathDialog(SelectedWhich, Selected->d.math.dest, - Selected->d.math.op1, Selected->d.math.op2); - break; - - case ELEM_RES: - ShowResetDialog(Selected->d.reset.name); - break; - - case ELEM_MOVE: - ShowMoveDialog(Selected->d.move.dest, Selected->d.move.src); - break; - - case ELEM_SET_PWM: - ShowSetPwmDialog(Selected->d.setPwm.name, - &(Selected->d.setPwm.targetFreq)); - break; - - case ELEM_READ_ADC: - ShowReadAdcDialog(Selected->d.readAdc.name+1); - break; - - case ELEM_UART_RECV: - case ELEM_UART_SEND: - ShowUartDialog(SelectedWhich, Selected->d.uart.name); - break; - - case ELEM_PERSIST: - ShowPersistDialog(Selected->d.persist.var); - break; - - case ELEM_SHIFT_REGISTER: - ShowShiftRegisterDialog(Selected->d.shiftRegister.name, - &(Selected->d.shiftRegister.stages)); - break; - - case ELEM_FORMATTED_STRING: - ShowFormattedStringDialog(Selected->d.fmtdStr.var, - Selected->d.fmtdStr.string); - break; - - case ELEM_PIECEWISE_LINEAR: - ShowPiecewiseLinearDialog(Selected); - break; - - case ELEM_LOOK_UP_TABLE: - ShowLookUpTableDialog(Selected); - break; - } +// if(!Selected || Selected->selectedState == SELECTED_NONE) return; + +// switch(SelectedWhich) { +// case ELEM_COMMENT: +// ShowCommentDialog(Selected->d.comment.str); +// break; + +// case ELEM_CONTACTS: +// ShowContactsDialog(&(Selected->d.contacts.negated), +// Selected->d.contacts.name); +// break; + +// case ELEM_COIL: +// ShowCoilDialog(&(Selected->d.coil.negated), +// &(Selected->d.coil.setOnly), &(Selected->d.coil.resetOnly), +// Selected->d.coil.name); +// break; + +// case ELEM_TON: +// case ELEM_TOF: +// case ELEM_RTO: +// ShowTimerDialog(SelectedWhich, &(Selected->d.timer.delay), +// Selected->d.timer.name); +// break; + +// case ELEM_CTU: +// case ELEM_CTD: +// case ELEM_CTC: +// ShowCounterDialog(SelectedWhich, &(Selected->d.counter.max), +// Selected->d.counter.name); +// break; + +// case ELEM_EQU: +// case ELEM_NEQ: +// case ELEM_GRT: +// case ELEM_GEQ: +// case ELEM_LES: +// case ELEM_LEQ: +// ShowCmpDialog(SelectedWhich, Selected->d.cmp.op1, +// Selected->d.cmp.op2); +// break; + +// case ELEM_ADD: +// case ELEM_SUB: +// case ELEM_MUL: +// case ELEM_DIV: +// ShowMathDialog(SelectedWhich, Selected->d.math.dest, +// Selected->d.math.op1, Selected->d.math.op2); +// break; + +// case ELEM_RES: +// ShowResetDialog(Selected->d.reset.name); +// break; + +// case ELEM_MOVE: +// ShowMoveDialog(Selected->d.move.dest, Selected->d.move.src); +// break; + +// case ELEM_SET_PWM: +// ShowSetPwmDialog(Selected->d.setPwm.name, +// &(Selected->d.setPwm.targetFreq)); +// break; + +// case ELEM_READ_ADC: +// ShowReadAdcDialog(Selected->d.readAdc.name+1); +// break; + +// case ELEM_UART_RECV: +// case ELEM_UART_SEND: +// ShowUartDialog(SelectedWhich, Selected->d.uart.name); +// break; + +// case ELEM_PERSIST: +// ShowPersistDialog(Selected->d.persist.var); +// break; + +// case ELEM_SHIFT_REGISTER: +// ShowShiftRegisterDialog(Selected->d.shiftRegister.name, +// &(Selected->d.shiftRegister.stages)); +// break; + +// case ELEM_FORMATTED_STRING: +// ShowFormattedStringDialog(Selected->d.fmtdStr.var, +// Selected->d.fmtdStr.string); +// break; + +// case ELEM_PIECEWISE_LINEAR: +// ShowPiecewiseLinearDialog(Selected); +// break; + +// case ELEM_LOOK_UP_TABLE: +// ShowLookUpTableDialog(Selected); +// break; +// } } //----------------------------------------------------------------------------- @@ -502,30 +502,30 @@ void EditSelectedElement(void) //----------------------------------------------------------------------------- void EditElementMouseDoubleclick(int x, int y) { - x += ScrollXOffset; - - y += FONT_HEIGHT/2; - - int gx = (x - X_PADDING)/(POS_WIDTH*FONT_WIDTH); - int gy = (y - Y_PADDING)/(POS_HEIGHT*FONT_HEIGHT); - - gy += ScrollYOffset; - - if(InSimulationMode) { - ElemLeaf *l = DisplayMatrix[gx][gy]; - if(l && DisplayMatrixWhich[gx][gy] == ELEM_CONTACTS) { - char *name = l->d.contacts.name; - if(name[0] == 'X') { - SimulationToggleContact(name); - } - } else if(l && DisplayMatrixWhich[gx][gy] == ELEM_READ_ADC) { - ShowAnalogSliderPopup(l->d.readAdc.name); - } - } else { - if(DisplayMatrix[gx][gy] == Selected) { - EditSelectedElement(); - } - } +// x += ScrollXOffset; + +// y += FONT_HEIGHT/2; + +// int gx = (x - X_PADDING)/(POS_WIDTH*FONT_WIDTH); +// int gy = (y - Y_PADDING)/(POS_HEIGHT*FONT_HEIGHT); + +// gy += ScrollYOffset; + +// if(InSimulationMode) { +// ElemLeaf *l = DisplayMatrix[gx][gy]; +// if(l && DisplayMatrixWhich[gx][gy] == ELEM_CONTACTS) { +// char *name = l->d.contacts.name; +// if(name[0] == 'X') { +// SimulationToggleContact(name); +// } +// } else if(l && DisplayMatrixWhich[gx][gy] == ELEM_READ_ADC) { +// ShowAnalogSliderPopup(l->d.readAdc.name); +// } +// } else { +// if(DisplayMatrix[gx][gy] == Selected) { +// EditSelectedElement(); +// } +// } } //----------------------------------------------------------------------------- @@ -536,71 +536,71 @@ void EditElementMouseDoubleclick(int x, int y) //----------------------------------------------------------------------------- void MoveCursorMouseClick(int x, int y) { - x += ScrollXOffset; - - y += FONT_HEIGHT/2; - - int gx0 = (x - X_PADDING)/(POS_WIDTH*FONT_WIDTH); - int gy0 = (y - Y_PADDING)/(POS_HEIGHT*FONT_HEIGHT); - - int gx = gx0; - int gy = gy0 + ScrollYOffset; - - if(VALID_LEAF(DisplayMatrix[gx][gy])) { - int i, j; - for(i = 0; i < DISPLAY_MATRIX_X_SIZE; i++) { - for(j = 0; j < DISPLAY_MATRIX_Y_SIZE; j++) { - if(DisplayMatrix[i][j]) - DisplayMatrix[i][j]->selectedState = SELECTED_NONE; - } - } - int dx = x - (gx0*POS_WIDTH*FONT_WIDTH + X_PADDING); - int dy = y - (gy0*POS_HEIGHT*FONT_HEIGHT + Y_PADDING); - - int dtop = dy; - int dbottom = POS_HEIGHT*FONT_HEIGHT - dy; - int dleft = dx; - int dright = POS_WIDTH*FONT_WIDTH - dx; - - int extra = 1; - if(DisplayMatrixWhich[gx][gy] == ELEM_COMMENT) { - dleft += gx*POS_WIDTH*FONT_WIDTH; - dright += (ColsAvailable - gx - 1)*POS_WIDTH*FONT_WIDTH; - extra = ColsAvailable; - } else { - if((gx > 0) && (DisplayMatrix[gx-1][gy] == DisplayMatrix[gx][gy])) { - dleft += POS_WIDTH*FONT_WIDTH; - extra = 2; - } - if((gx < (DISPLAY_MATRIX_X_SIZE-1)) && - (DisplayMatrix[gx+1][gy] == DisplayMatrix[gx][gy])) - { - dright += POS_WIDTH*FONT_WIDTH; - extra = 2; - } - } - - int decideX = (dright - dleft); - int decideY = (dtop - dbottom); - - decideY = decideY*3*extra; - - int state; - if(abs(decideY) > abs(decideX)) { - if(decideY > 0) { - state = SELECTED_BELOW; - } else { - state = SELECTED_ABOVE; - } - } else { - if(decideX > 0) { - state = SELECTED_LEFT; - } else { - state = SELECTED_RIGHT; - } - } - SelectElement(gx, gy, state); - } +// x += ScrollXOffset; + +// y += FONT_HEIGHT/2; + +// int gx0 = (x - X_PADDING)/(POS_WIDTH*FONT_WIDTH); +// int gy0 = (y - Y_PADDING)/(POS_HEIGHT*FONT_HEIGHT); + +// int gx = gx0; +// int gy = gy0 + ScrollYOffset; + +// if(VALID_LEAF(DisplayMatrix[gx][gy])) { +// int i, j; +// for(i = 0; i < DISPLAY_MATRIX_X_SIZE; i++) { +// for(j = 0; j < DISPLAY_MATRIX_Y_SIZE; j++) { +// if(DisplayMatrix[i][j]) +// DisplayMatrix[i][j]->selectedState = SELECTED_NONE; +// } +// } +// int dx = x - (gx0*POS_WIDTH*FONT_WIDTH + X_PADDING); +// int dy = y - (gy0*POS_HEIGHT*FONT_HEIGHT + Y_PADDING); + +// int dtop = dy; +// int dbottom = POS_HEIGHT*FONT_HEIGHT - dy; +// int dleft = dx; +// int dright = POS_WIDTH*FONT_WIDTH - dx; + +// int extra = 1; +// if(DisplayMatrixWhich[gx][gy] == ELEM_COMMENT) { +// dleft += gx*POS_WIDTH*FONT_WIDTH; +// dright += (ColsAvailable - gx - 1)*POS_WIDTH*FONT_WIDTH; +// extra = ColsAvailable; +// } else { +// if((gx > 0) && (DisplayMatrix[gx-1][gy] == DisplayMatrix[gx][gy])) { +// dleft += POS_WIDTH*FONT_WIDTH; +// extra = 2; +// } +// if((gx < (DISPLAY_MATRIX_X_SIZE-1)) && +// (DisplayMatrix[gx+1][gy] == DisplayMatrix[gx][gy])) +// { +// dright += POS_WIDTH*FONT_WIDTH; +// extra = 2; +// } +// } + +// int decideX = (dright - dleft); +// int decideY = (dtop - dbottom); + +// decideY = decideY*3*extra; + +// int state; +// if(abs(decideY) > abs(decideX)) { +// if(decideY > 0) { +// state = SELECTED_BELOW; +// } else { +// state = SELECTED_ABOVE; +// } +// } else { +// if(decideX > 0) { +// state = SELECTED_LEFT; +// } else { +// state = SELECTED_RIGHT; +// } +// } +// SelectElement(gx, gy, state); +// } } //----------------------------------------------------------------------------- @@ -609,49 +609,49 @@ void MoveCursorMouseClick(int x, int y) //----------------------------------------------------------------------------- void MoveCursorNear(int gx, int gy) { - int out = 0; - - for(out = 0; out < 8; out++) { - if(gx - out >= 0) { - if(VALID_LEAF(DisplayMatrix[gx-out][gy])) { - SelectElement(gx-out, gy, SELECTED_RIGHT); - return; - } - } - if(gx + out < DISPLAY_MATRIX_X_SIZE) { - if(VALID_LEAF(DisplayMatrix[gx+out][gy])) { - SelectElement(gx+out, gy, SELECTED_LEFT); - return; - } - } - if(gy - out >= 0) { - if(VALID_LEAF(DisplayMatrix[gx][gy-out])) { - SelectElement(gx, gy-out, SELECTED_BELOW); - return; - } - } - if(gy + out < DISPLAY_MATRIX_Y_SIZE) { - if(VALID_LEAF(DisplayMatrix[gx][gy+out])) { - SelectElement(gx, gy+out, SELECTED_ABOVE); - return; - } - } - - if(out == 1) { - // Now see if we have a straight shot to the right; might be far - // if we have to go up to a coil or other end of line element. - int across; - for(across = 1; gx+across < DISPLAY_MATRIX_X_SIZE; across++) { - if(VALID_LEAF(DisplayMatrix[gx+across][gy])) { - SelectElement(gx+across, gy, SELECTED_LEFT); - return; - } - if(!DisplayMatrix[gx+across][gy]) break; - } - } - } - - MoveCursorTopLeft(); +// int out = 0; + +// for(out = 0; out < 8; out++) { +// if(gx - out >= 0) { +// if(VALID_LEAF(DisplayMatrix[gx-out][gy])) { +// SelectElement(gx-out, gy, SELECTED_RIGHT); +// return; +// } +// } +// if(gx + out < DISPLAY_MATRIX_X_SIZE) { +// if(VALID_LEAF(DisplayMatrix[gx+out][gy])) { +// SelectElement(gx+out, gy, SELECTED_LEFT); +// return; +// } +// } +// if(gy - out >= 0) { +// if(VALID_LEAF(DisplayMatrix[gx][gy-out])) { +// SelectElement(gx, gy-out, SELECTED_BELOW); +// return; +// } +// } +// if(gy + out < DISPLAY_MATRIX_Y_SIZE) { +// if(VALID_LEAF(DisplayMatrix[gx][gy+out])) { +// SelectElement(gx, gy+out, SELECTED_ABOVE); +// return; +// } +// } + +// if(out == 1) { +// // Now see if we have a straight shot to the right; might be far +// // if we have to go up to a coil or other end of line element. +// int across; +// for(across = 1; gx+across < DISPLAY_MATRIX_X_SIZE; across++) { +// if(VALID_LEAF(DisplayMatrix[gx+across][gy])) { +// SelectElement(gx+across, gy, SELECTED_LEFT); +// return; +// } +// if(!DisplayMatrix[gx+across][gy]) break; +// } +// } +// } + +// MoveCursorTopLeft(); } //----------------------------------------------------------------------------- diff --git a/ldmicro/simpledialog.cpp b/ldmicro/simpledialog.cpp index 3e88adc..7edfc5c 100644 --- a/ldmicro/simpledialog.cpp +++ b/ldmicro/simpledialog.cpp @@ -22,8 +22,8 @@ // operands. Try to reuse code a bit. // Jonathan Westhues, Nov 2004 //----------------------------------------------------------------------------- -#include <windows.h> -#include <commctrl.h> +#include "linuxUI.h" +//#include <commctrl.h> #include <stdio.h> #include <stdlib.h> diff --git a/ldmicro/simulate.cpp b/ldmicro/simulate.cpp index 7e2f204..57da046 100644 --- a/ldmicro/simulate.cpp +++ b/ldmicro/simulate.cpp @@ -24,8 +24,8 @@ // timers, etc. // Jonathan Westhues, Nov 2004 //----------------------------------------------------------------------------- -#include <windows.h> -#include <commctrl.h> +#include "linuxUI.h" +//#include <commctrl.h> #include <stdio.h> #include <stdlib.h> #include <limits.h> diff --git a/ldmicro/undoredo.cpp b/ldmicro/undoredo.cpp index 43e6693..69831d8 100644 --- a/ldmicro/undoredo.cpp +++ b/ldmicro/undoredo.cpp @@ -22,7 +22,7 @@ // the entire program at all times. // Jonathan Westhues, split May 2005 //----------------------------------------------------------------------------- -#include <windows.h> +#include "linuxUI.h" #include <stdio.h> #include <stdlib.h> @@ -198,9 +198,9 @@ void UndoUndo(void) } else { SetUndoEnabled(FALSE, TRUE); } - RefreshControlsToSettings(); - RefreshScrollbars(); - InvalidateRect(MainWindow, NULL, FALSE); + // RefreshControlsToSettings(); + // RefreshScrollbars(); + // InvalidateRect(MainWindow, NULL, FALSE); } //----------------------------------------------------------------------------- @@ -221,9 +221,9 @@ void UndoRedo(void) } else { SetUndoEnabled(TRUE, FALSE); } - RefreshControlsToSettings(); - RefreshScrollbars(); - InvalidateRect(MainWindow, NULL, FALSE); + //RefreshControlsToSettings(); + //RefreshScrollbars(); + //InvalidateRect(MainWindow, NULL, FALSE); } //----------------------------------------------------------------------------- |