First version of the OpenPLC Ladder Editor

Code based on LDMicro 2.2
This commit is contained in:
Thiago Alves 2014-07-22 20:08:56 -03:00
parent 0b37f9351f
commit e30c4b3609
124 changed files with 36264 additions and 0 deletions

Binary file not shown.

View File

@ -0,0 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual C++ Express 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "OpenPLC Ladder", "OpenPLC Ladder.vcxproj", "{C0AFE9E4-6360-780F-4F27-8A4716EA841F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C0AFE9E4-6360-780F-4F27-8A4716EA841F}.Debug|Win32.ActiveCfg = Debug|Win32
{C0AFE9E4-6360-780F-4F27-8A4716EA841F}.Debug|Win32.Build.0 = Debug|Win32
{C0AFE9E4-6360-780F-4F27-8A4716EA841F}.Release|Win32.ActiveCfg = Release|Win32
{C0AFE9E4-6360-780F-4F27-8A4716EA841F}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

Binary file not shown.

View File

@ -0,0 +1,114 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<Optimization>Disabled</Optimization>
</ClCompile>
<Link>
<TargetMachine>MachineX86</TargetMachine>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<TargetMachine>MachineX86</TargetMachine>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Windows</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="common\win32\freeze.cpp" />
<ClCompile Include="ldmicro\ansic.cpp" />
<ClCompile Include="ldmicro\avr.cpp" />
<ClCompile Include="ldmicro\circuit.cpp" />
<ClCompile Include="ldmicro\coildialog.cpp" />
<ClCompile Include="ldmicro\commentdialog.cpp" />
<ClCompile Include="ldmicro\compilecommon.cpp" />
<ClCompile Include="ldmicro\confdialog.cpp" />
<ClCompile Include="ldmicro\contactsdialog.cpp" />
<ClCompile Include="ldmicro\draw.cpp" />
<ClCompile Include="ldmicro\draw_outputdev.cpp" />
<ClCompile Include="ldmicro\helpdialog.cpp" />
<ClCompile Include="ldmicro\intcode.cpp" />
<ClCompile Include="ldmicro\interpreted.cpp" />
<ClCompile Include="ldmicro\iolist.cpp" />
<ClCompile Include="ldmicro\lang.cpp" />
<ClCompile Include="ldmicro\ldinterpret.c" />
<ClCompile Include="ldmicro\ldmicro.cpp" />
<ClCompile Include="ldmicro\loadsave.cpp" />
<ClCompile Include="ldmicro\lutdialog.cpp" />
<ClCompile Include="ldmicro\maincontrols.cpp" />
<ClCompile Include="ldmicro\miscutil.cpp" />
<ClCompile Include="ldmicro\obj\helptext.cpp" />
<ClCompile Include="ldmicro\pic16.cpp" />
<ClCompile Include="ldmicro\resetdialog.cpp" />
<ClCompile Include="ldmicro\schematic.cpp" />
<ClCompile Include="ldmicro\simpledialog.cpp" />
<ClCompile Include="ldmicro\simulate.cpp" />
<ClCompile Include="ldmicro\undoredo.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="common\win32\freeze.h" />
<ClInclude Include="ldmicro\intcode.h" />
<ClInclude Include="ldmicro\ldmicro.h" />
<ClInclude Include="ldmicro\mcutable.h" />
<ClInclude Include="ldmicro\obj\lang-tables.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="ldmicro\ldmicro.rc" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,128 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="common\win32\freeze.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ldmicro\ansic.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ldmicro\avr.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ldmicro\circuit.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ldmicro\coildialog.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ldmicro\commentdialog.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ldmicro\compilecommon.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ldmicro\confdialog.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ldmicro\contactsdialog.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ldmicro\draw.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ldmicro\draw_outputdev.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ldmicro\helpdialog.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ldmicro\intcode.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ldmicro\interpreted.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ldmicro\iolist.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ldmicro\lang.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ldmicro\ldmicro.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ldmicro\loadsave.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ldmicro\lutdialog.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ldmicro\maincontrols.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ldmicro\miscutil.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ldmicro\pic16.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ldmicro\resetdialog.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ldmicro\schematic.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ldmicro\simpledialog.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ldmicro\simulate.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ldmicro\undoredo.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ldmicro\ldinterpret.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="ldmicro\obj\helptext.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="common\win32\freeze.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="ldmicro\intcode.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="ldmicro\ldmicro.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="ldmicro\mcutable.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="ldmicro\obj\lang-tables.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="ldmicro\ldmicro.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
</Project>

View File

@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
</Project>

View File

@ -0,0 +1,208 @@
/*
* A library for storing parameters in the registry.
*
* Jonathan Westhues, 2002
*/
#include <windows.h>
#include <stdlib.h>
#include <stdio.h>
/*
* store a window's position in the registry, or fail silently if the registry calls don't work
*/
void FreezeWindowPosF(HWND hwnd, char *subKey, char *name)
{
RECT r;
GetWindowRect(hwnd, &r);
HKEY software;
if(RegOpenKeyEx(HKEY_CURRENT_USER, "Software", 0, KEY_ALL_ACCESS, &software) != ERROR_SUCCESS)
return;
char *keyName = (char *)malloc(strlen(name) + 30);
if(!keyName)
return;
HKEY sub;
if(RegCreateKeyEx(software, subKey, 0, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &sub, NULL) != ERROR_SUCCESS)
return;
sprintf(keyName, "%s_left", name);
if(RegSetValueEx(sub, keyName, 0, REG_DWORD, (BYTE *)&(r.left), sizeof(DWORD)) != ERROR_SUCCESS)
return;
sprintf(keyName, "%s_right", name);
if(RegSetValueEx(sub, keyName, 0, REG_DWORD, (BYTE *)&(r.right), sizeof(DWORD)) != ERROR_SUCCESS)
return;
sprintf(keyName, "%s_top", name);
if(RegSetValueEx(sub, keyName, 0, REG_DWORD, (BYTE *)&(r.top), sizeof(DWORD)) != ERROR_SUCCESS)
return;
sprintf(keyName, "%s_bottom", name);
if(RegSetValueEx(sub, keyName, 0, REG_DWORD, (BYTE *)&(r.bottom), sizeof(DWORD)) != ERROR_SUCCESS)
return;
sprintf(keyName, "%s_maximized", name);
DWORD v = IsZoomed(hwnd);
if(RegSetValueEx(sub, keyName, 0, REG_DWORD, (BYTE *)&(v), sizeof(DWORD)) != ERROR_SUCCESS)
return;
free(keyName);
}
static void Clamp(LONG *v, LONG min, LONG max)
{
if(*v < min) *v = min;
if(*v > max) *v = max;
}
/*
* retrieve a window's position from the registry, or do nothing if there is no info saved
*/
void ThawWindowPosF(HWND hwnd, char *subKey, char *name)
{
HKEY software;
if(RegOpenKeyEx(HKEY_CURRENT_USER, "Software", 0, KEY_ALL_ACCESS, &software) != ERROR_SUCCESS)
return;
HKEY sub;
if(RegOpenKeyEx(software, subKey, 0, KEY_ALL_ACCESS, &sub) != ERROR_SUCCESS)
return;
char *keyName = (char *)malloc(strlen(name) + 30);
if(!keyName)
return;
DWORD l;
RECT r;
sprintf(keyName, "%s_left", name);
l = sizeof(DWORD);
if(RegQueryValueEx(sub, keyName, NULL, NULL, (BYTE *)&(r.left), &l) != ERROR_SUCCESS)
return;
sprintf(keyName, "%s_right", name);
l = sizeof(DWORD);
if(RegQueryValueEx(sub, keyName, NULL, NULL, (BYTE *)&(r.right), &l) != ERROR_SUCCESS)
return;
sprintf(keyName, "%s_top", name);
l = sizeof(DWORD);
if(RegQueryValueEx(sub, keyName, NULL, NULL, (BYTE *)&(r.top), &l) != ERROR_SUCCESS)
return;
sprintf(keyName, "%s_bottom", name);
l = sizeof(DWORD);
if(RegQueryValueEx(sub, keyName, NULL, NULL, (BYTE *)&(r.bottom), &l) != ERROR_SUCCESS)
return;
sprintf(keyName, "%s_maximized", name);
DWORD v;
l = sizeof(DWORD);
if(RegQueryValueEx(sub, keyName, NULL, NULL, (BYTE *)&v, &l) != ERROR_SUCCESS)
return;
if(v)
ShowWindow(hwnd, SW_MAXIMIZE);
RECT dr;
GetWindowRect(GetDesktopWindow(), &dr);
// If it somehow ended up off-screen, then put it back.
Clamp(&(r.left), dr.left, dr.right);
Clamp(&(r.right), dr.left, dr.right);
Clamp(&(r.top), dr.top, dr.bottom);
Clamp(&(r.bottom), dr.top, dr.bottom);
if(r.right - r.left < 100) {
r.left -= 300; r.right += 300;
}
if(r.bottom - r.top < 100) {
r.top -= 300; r.bottom += 300;
}
Clamp(&(r.left), dr.left, dr.right);
Clamp(&(r.right), dr.left, dr.right);
Clamp(&(r.top), dr.top, dr.bottom);
Clamp(&(r.bottom), dr.top, dr.bottom);
MoveWindow(hwnd, r.left, r.top, r.right - r.left, r.bottom - r.top, TRUE);
free(keyName);
}
/*
* store a DWORD setting in the registry
*/
void FreezeDWORDF(DWORD val, char *subKey, char *name)
{
HKEY software;
if(RegOpenKeyEx(HKEY_CURRENT_USER, "Software", 0, KEY_ALL_ACCESS, &software) != ERROR_SUCCESS)
return;
HKEY sub;
if(RegCreateKeyEx(software, subKey, 0, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &sub, NULL) != ERROR_SUCCESS)
return;
if(RegSetValueEx(sub, name, 0, REG_DWORD, (BYTE *)&val, sizeof(DWORD)) != ERROR_SUCCESS)
return;
}
/*
* retrieve a DWORD setting, or return the default if that setting is unavailable
*/
DWORD ThawDWORDF(DWORD val, char *subKey, char *name)
{
HKEY software;
if(RegOpenKeyEx(HKEY_CURRENT_USER, "Software", 0, KEY_ALL_ACCESS, &software) != ERROR_SUCCESS)
return val;
HKEY sub;
if(RegOpenKeyEx(software, subKey, 0, KEY_ALL_ACCESS, &sub) != ERROR_SUCCESS)
return val;
DWORD l = sizeof(DWORD);
DWORD v;
if(RegQueryValueEx(sub, name, NULL, NULL, (BYTE *)&v, &l) != ERROR_SUCCESS)
return val;
return v;
}
/*
* store a string setting in the registry
*/
void FreezeStringF(char *val, char *subKey, char *name)
{
HKEY software;
if(RegOpenKeyEx(HKEY_CURRENT_USER, "Software", 0, KEY_ALL_ACCESS, &software) != ERROR_SUCCESS)
return;
HKEY sub;
if(RegCreateKeyEx(software, subKey, 0, "", REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &sub, NULL) != ERROR_SUCCESS)
return;
if(RegSetValueEx(sub, name, 0, REG_SZ, (BYTE *)val, strlen(val)+1) != ERROR_SUCCESS)
return;
}
/*
* retrieve a string setting, or return the default if that setting is unavailable
*/
void ThawStringF(char *val, int max, char *subKey, char *name)
{
HKEY software;
if(RegOpenKeyEx(HKEY_CURRENT_USER, "Software", 0, KEY_ALL_ACCESS, &software) != ERROR_SUCCESS)
return;
HKEY sub;
if(RegOpenKeyEx(software, subKey, 0, KEY_ALL_ACCESS, &sub) != ERROR_SUCCESS)
return;
DWORD l = max;
if(RegQueryValueEx(sub, name, NULL, NULL, (BYTE *)val, &l) != ERROR_SUCCESS)
return;
if(l >= (DWORD)max) return;
val[l] = '\0';
return;
}

View File

@ -0,0 +1,33 @@
/*
* A library for storing parameters in the registry.
*
* Jonathan Westhues, 2002
*/
#ifndef __FREEZE_H
#define __FREEZE_H
#ifndef FREEZE_SUBKEY
#error must define FREEZE_SUBKEY to a string uniquely identifying the app
#endif
#define FreezeWindowPos(hwnd) FreezeWindowPosF(hwnd, FREEZE_SUBKEY, #hwnd)
void FreezeWindowPosF(HWND hWnd, char *subKey, char *name);
#define ThawWindowPos(hwnd) ThawWindowPosF(hwnd, FREEZE_SUBKEY, #hwnd)
void ThawWindowPosF(HWND hWnd, char *subKey, char *name);
#define FreezeDWORD(val) FreezeDWORDF(val, FREEZE_SUBKEY, #val)
void FreezeDWORDF(DWORD val, char *subKey, char *name);
#define ThawDWORD(val) val = ThawDWORDF(val, FREEZE_SUBKEY, #val)
DWORD ThawDWORDF(DWORD val, char *subKey, char *name);
#define FreezeString(val) FreezeStringF(val, FREEZE_SUBKEY, #val)
void FreezeStringF(char *val, char *subKey, char *name);
#define ThawString(val, max) ThawStringF(val, max, FREEZE_SUBKEY, #val)
void ThawStringF(char *val, int max, char *subKey, char *name);
#endif

View File

@ -0,0 +1,182 @@
== Release 2.2
* Fix a problem with the ANSI C target when the program had bit and
integer variables with the same name. Note that this changes the
names of the symbols in the generated C program; so a system that
uses "magic variables" with this target for I/O must be updated
to use the new names.
* Fix a subtle bug in the PIC16 add and subtract routines, where
operations of the form B = A - B could fail.
* The piecewise linear tables were broken for the AVRs; fix that.
== Release 2.1
* For the AVR UARTs, poll UDRE instead of TXC. The formatted string op
was broken on some targets, should now be fixed.
* Don't draw selected op in bold font; that looks ugly under Vista.
== Release 2.0
* Add PIC16F886 and PIC16F887 targets.
* Fix display bug in the list to select an I/O pin.
* Fix bug where PIC16 UART locks up forever after a framing error when
the cycle time is faster than one byte time.
* Fix bug where PIC16 outputs could briefly glitch high at startup.
* Clear PCLATH in PIC16 boot vector, since some bootloaders expect that.
== Release 1.9
* Modify PIC16 boot vectors to work with many bootloaders.
== Release 1.8
* Fix modification of a constant string that blew up in new MSVC++
compiler.
* Add Italian, Turkish, Portuguese.
== Release 1.7
* Make the source compile with latest version of MSVC++; overloaded
functions behave a bit differently.
* Recover from (and ignore) UART errors on the PIC16 target, instead
of getting stuck forever.
* Whenever contacts bound to an output pin (Yfoo) were edited, they
reverted to an input pin (Xfoo); now fixed.
* Don't abort on too-wide program; instead display nice message.
* It was possible (by adding and deleting contacts/coils with the
same name) to end up with two bit variables bound to the same
physical I/O pin; now fixed.
* File -> Open was correct, but Ctrl+O failed to ask about unsaved
changes before opening requested file; now both are correct.
* Add Spanish user interface strings.
== Release 1.6
* Internationalize the user interface strings; we now have versions
in English, French, and German.
* First source release, under the GPLv3.
== Release 1.5
* Add untested support for ATmega32.
* Remove annoying lag in user interface when editing large (hundreds
of ops) programs
== Release 1.4
* Fix a terrible bug in the target for the ATmega8; because there is
no PORTA/DDRA/PINA, I broke an assumption in my code and failed
to set up the port directions.
== Release 1.3
* Timer delays are represented as a signed 32-bit integer count
of microseconds. If the user provides a delay >= 2**31 us, then
show an error instead of just letting things wrap.
* Change the start-up behaviour of TOF timers. Previously they would
start from a count of zero, so they would be on (independent of
rung-in) until they counted themselves off. Now they start out
at full count (as if rung-in has been low for a very long time),
so rung-out is low until rung-in goes high.
== Release 1.2
* Add an untested target for the ATmega8
* Add a special instruction to simplify piecewise linear tables
* Fix some user interface bugs: it was possible to drag the top of the
I/O list so high that you couldn't grab it again, and there were
some cases in which the pin number associated with UART and PWM
variables was not displayed
== Release 1.1
* Fix persistent variables, which were broken for the PIC16F628
== Release 1.0
* Fix bug in which the filename that appears in the title bar of the
main window failed to get updated when opening/saving a file using
the keyboard shortcuts (Ctrl+O/+S)
* Fix simulation crash when the ladder logic program divides by zero
* Fix jumpy scrolling on programs with many rungs of logic when the
cursor is off-screen
== Release 0.9
* Fix bug with formatted string op on the AVR
* Fix previously-untested ATmega16 and ATmega162 targets, which were
completely broken
=== Release 0.8
* Fix PORTA on the PIC16F819 (came up assigned to ADCs, of course)
=== Release 0.7
* Support arbitrary character (\xAB) escapes in formatted string op
* Fix a bug in which the title bar of the main window was not updated
=== Release 0.6
* Add formatted text output over serial (e.g. to an LCD or a PC)
* Add ability to make variables persistent (i.e. auto-saved in EEPROM)
* Add look-up table instructions
* Fix a bug with the PORTE pins on some AVRs
* Fix miscellaneous user interface bugs
=== Release 0.5
* Interpretable byte code target
* Shift register and master control relay instructions
=== Release 0.4
* Make ADCs work on the AVRs
=== Release 0.3
* Support serial for AVR
* Support PWM for PIC16 and AVR
* Show program filename in title bar of main window
* Untested support for PIC16F88, F819, F876
* Generate ANSI C code from ladder diagram
=== Release 0.2
* Support serial communications (using UART), PIC16 only
* Support ADC reads, PIC16 only
* Simulation environment for ADC and serial
* Support ASCII character constant ('a') literals
* Fix PORTA pins in PIC16F628 (should assign as GPIO, not to comparator)
* Make file open/save dialogs work under Win98
* Fix PORTA/PORTE pins in PIC16F877 (should assign as GPIO, not to ADC)
* Add ability to comment your program
* Fix bug when a relative filename is given on the command line and
the `Compile As' dialog is later used to specify a destination in
a different directory
=== Release 0.1
Initial release

View File

@ -0,0 +1,675 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The GNU General Public License is a free, copyleft license for
software and other kinds of works.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
the GNU General Public License is intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users. We, the Free Software Foundation, use the
GNU General Public License for most of our software; it applies also to
any other work released this way by its authors. You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to prevent others from denying you
these rights or asking you to surrender the rights. Therefore, you have
certain responsibilities if you distribute copies of the software, or if
you modify it: responsibilities to respect the freedom of others.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must pass on to the recipients the same
freedoms that you received. You must make sure that they, too, receive
or can get the source code. And you must show them these terms so they
know their rights.
Developers that use the GNU GPL protect your rights with two steps:
(1) assert copyright on the software, and (2) offer you this License
giving you legal permission to copy, distribute and/or modify it.
For the developers' and authors' protection, the GPL clearly explains
that there is no warranty for this free software. For both users' and
authors' sake, the GPL requires that modified versions be marked as
changed, so that their problems will not be attributed erroneously to
authors of previous versions.
Some devices are designed to deny users access to install or run
modified versions of the software inside them, although the manufacturer
can do so. This is fundamentally incompatible with the aim of
protecting users' freedom to change the software. The systematic
pattern of such abuse occurs in the area of products for individuals to
use, which is precisely where it is most unacceptable. Therefore, we
have designed this version of the GPL to prohibit the practice for those
products. If such problems arise substantially in other domains, we
stand ready to extend this provision to those domains in future versions
of the GPL, as needed to protect the freedom of users.
Finally, every program is threatened constantly by software patents.
States should not allow patents to restrict development and use of
software on general-purpose computers, but in those that do, we wish to
avoid the special danger that patents applied to a free program could
make it effectively proprietary. To prevent this, the GPL assures that
patents cannot be used to render the program non-free.
The precise terms and conditions for copying, distribution and
modification follow.
TERMS AND CONDITIONS
0. Definitions.
"This License" refers to version 3 of the GNU General Public License.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
A "covered work" means either the unmodified Program or a work based
on the Program.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
1. Source Code.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The Corresponding Source for a work in source code form is that
same work.
2. Basic Permissions.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
13. Use with the GNU Affero General Public License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU Affero General Public License into a single
combined work, and to convey the resulting work. The terms of this
License will continue to apply to the part which is the covered work,
but the special requirements of the GNU Affero General Public License,
section 13, concerning interaction through a network will apply to the
combination as such.
14. Revised Versions of this License.
The Free Software Foundation may publish revised and/or new versions of
the GNU General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU General Public License, you may choose any version ever published
by the Free Software Foundation.
If the Program specifies that a proxy can decide which future
versions of the GNU General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
Later license versions may give you additional or different
permissions. However, no additional obligations are imposed on any
author or copyright holder as a result of your choosing to follow a
later version.
15. Disclaimer of Warranty.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
state the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
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/>.
Also add information on how to contact you by electronic and paper mail.
If the program does terminal interaction, make it output a short
notice like this when it starts in an interactive mode:
<program> Copyright (C) <year> <name of author>
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, your program's commands
might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.

View File

@ -0,0 +1,137 @@
LDMICRO INTERNALS
=================
This document describes LDmicro's internal structure. I intend it as a
quick reference for my own use.
ADDING A NEW ELEM_XXX LADDER INSTRUCTION
========================================
It is necessary to make changes in the following places:
* ldmicro.h -- add the new ELEM_XXX #define
-- add the new MNU_XXX for the menu to add it
-- add any necessary data structures to ElemLeaf
-- add prototypes for newly created extern functions
-- if it is a leaf (it almost certainly is), to
CASE_LEAF
* maincontrols. -- add the code to create the menu
cpp -- add the code to enable/disable the menu when we
go from `edit' to `simulate' mode
* iolist.cpp -- add to routines that build the I/O list; even if
it does not affect the I/O list, it must be added
to the case statement in ExtractNamesFromCircuit,
so that it explicitly does nothing
* draw.cpp -- routines to draw the element on the ladder diagram
* loadsave.cpp -- routines to load and save the element to the
xxx.ld file
* intcode.cpp -- routines to generate intermediate code from the
instruction
* schematic.cpp -- WhatCanWeDoFromCursorAndTopology, update the
enabled state of the menus (what can be inserted
above/below/left/right, etc.) based on selection
-- EditSelectedElement, self-explanatory
* ldmicro.cpp -- typically menu/keyboard handlers to call the
AddXXX function to insert the element
* circuit.cpp -- the new AddXXX function, to add the element at the
cursor point
* simulate.cpp -- CheckVariableNamesCircuit, the design rules check
to ensure that e.g. same Tname isn't used with
two timers
* xxxdialog.cpp -- an `edit element' dialog if necessary, somewhere
(most likely to be simpledialog.cpp, using that)
REPRESENTATION OF THE PROGRAM
=============================
(adapted from an email message, so the tone's a little odd, sorry)
A ladder program can be thought of as a series-parallel network. Each
rung is a series circuit; this circuit contains either leaf elements
(like contacts, coils, etc.), or parallel circuits. The parallel circuits
contain either leaf elements or series subcircuits. If you look at a
.ld file in a text editor then you can see that I chose to represent
the program in this way.
This representation makes the compiler a relatively simple problem.
Imagine that you wish to write a routine to evaluate a circuit. This
routine will take as an input the circuit's rung-in condition, and
provide as an output its rung-out. For a circuit consisting of a single
leaf element this is straightforward; if you look at the Allen Bradley
documentation then you will see that this is actually how they specify
their instructions. For example, the rung-out condition of a set of
contacts is false if either its rung-in condition is false or the input
corresponding to the set of contacts is false. Let us say that for a
leaf element L, the output
Rout = L(Rin).
If that element is a set of contacts named `Xin,' then
L(Rin) := Rin && (Xin is HIGH).
(I will use && for AND, and || for OR.)
Next we must figure out how to compile a series circuit, for example (left
to right), sub-circuits A, B, and C in series. In that case, the rung-in
condition for A is the rung-in condition for the circuit. Then the rung-in
condition for B is the rung-out condition for B, the rung-in condition for C
is the rung-out condition for B, and the rung-out condition for the whole
circuit is the rung-out condition for C. So if the whole series circuit is
X, then
X(Rin) := C(B(A(Rin))).
Notice that the series circuit is not defined in terms of a boolean AND.
That would work if you just had contacts, but for ops like TOF, whose
rung-out can be true when their rung-ins are false, it breaks down.
For a parallel circuit, for example sub-circuits A, B, and C in parallel,
the rung-in condition for each of the sub-circuits is the rung-in
condition for the whole circuit, and the rung-out condition is true if
at least one of the rung-out conditions of the subcircuits is true. So
if the whole parallel circuit is Y, then
Y(Rin) := A(Rin) || B(Rin) || C(Rin).
For the series or parallel circuits, the sub-circuits A, B, or C need not
be leaf elements; they could be parallel or series circuits themselves. In
that case you would have to apply the appropriate definition, maybe
recursively (you could have a series circuit that contains a parallel
circuit that contains another parallel circuit). Once you have written
the program in that form, as cascaded and OR'd simple functions, any
textbook in compilers can tell you what to do with it, if it is not
obvious already.
As I said, though, there are many implementation details. For example,
I currently support five different targets: PIC16, AVR, ANSI C code,
interpretable byte code, and the simulator. To reduce the amount of work
that I must do, I have a simple intermediate representation, with only
a couple dozen ops. The ladder logic is compiled to intermediate code,
and the intermediate code is then compiled to whatever I need by the
appropriate back end. This intermediate code is designed to be as simple
and as easy to compile as possible, to minimize the time required for me
to maintain five back ends. That is one of the major reasons why LDmicro
generates poor code; a more expressive intcode would make it possible
to write better back ends, but at the cost of implementation time.
If you would like to see how I compile ladder logic to a procedural
language, then I would suggest that you look at the code generated by the
ANSI C back end.
Jonathan Westhues, Mar 2006, Oct 2007

View File

@ -0,0 +1,76 @@
DEFINES = /D_WIN32_WINNT=0x400 /DISOLATION_AWARE_ENABLED /D_WIN32_IE=0x400 /DWIN32_LEAN_AND_MEAN /DWIN32 /D$(D)
CFLAGS = /W3 /nologo -I..\common\win32 /O2 /D_CRT_SECURE_NO_WARNINGS /D_DEBUG /Zi
HEADERS = ..\common\win32\freeze.h ldmicro.h mcutable.h intcode.h
OBJDIR = obj
FREEZE = $(OBJDIR)\freeze.obj
LDOBJS = $(OBJDIR)\ldmicro.obj \
$(OBJDIR)\maincontrols.obj \
$(OBJDIR)\helpdialog.obj \
$(OBJDIR)\schematic.obj \
$(OBJDIR)\draw.obj \
$(OBJDIR)\draw_outputdev.obj \
$(OBJDIR)\circuit.obj \
$(OBJDIR)\undoredo.obj \
$(OBJDIR)\loadsave.obj \
$(OBJDIR)\simulate.obj \
$(OBJDIR)\commentdialog.obj \
$(OBJDIR)\contactsdialog.obj \
$(OBJDIR)\coildialog.obj \
$(OBJDIR)\simpledialog.obj \
$(OBJDIR)\resetdialog.obj \
$(OBJDIR)\lutdialog.obj \
$(OBJDIR)\confdialog.obj \
$(OBJDIR)\iolist.obj \
$(OBJDIR)\miscutil.obj \
$(OBJDIR)\lang.obj \
$(OBJDIR)\intcode.obj \
$(OBJDIR)\compilecommon.obj \
$(OBJDIR)\ansic.obj \
$(OBJDIR)\interpreted.obj \
$(OBJDIR)\pic16.obj \
$(OBJDIR)\avr.obj
HELPOBJ = $(OBJDIR)\helptext.obj
LIBS = user32.lib gdi32.lib comctl32.lib advapi32.lib
all: $(OBJDIR)/ldmicro.exe $(OBJDIR)/ldinterpret.exe
@cp $(OBJDIR)/ldmicro.exe .
@cp $(OBJDIR)/ldinterpret.exe .
@cd reg
@go.bat
@cd ..
clean:
rm -f obj/*
lang.cpp: $(OBJDIR)/lang-tables.h
$(OBJDIR)/lang-tables.h: lang*.txt
perl lang-tables.pl > $(OBJDIR)/lang-tables.h
$(OBJDIR)/ldinterpret.exe: ldinterpret.c
@$(CC) -Fe$(OBJDIR)/ldinterpret.exe $(LIBS) ldinterpret.c
$(OBJDIR)/ldmicro.exe: $(LDOBJS) $(FREEZE) $(HELPOBJ) $(OBJDIR)/ldmicro.res
@$(CC) $(DEFINES) $(CFLAGS) -Fe$(OBJDIR)/ldmicro.exe $(LDOBJS) $(FREEZE) $(HELPOBJ) $(OBJDIR)/ldmicro.res $(LIBS)
$(OBJDIR)/ldmicro.res: ldmicro.rc ldmicro.ico
@rc ldmicro.rc
@mv ldmicro.res $(OBJDIR)
$(LDOBJS): $(@B).cpp $(HEADERS)
@$(CC) $(CFLAGS) $(DEFINES) -c -Fo$(OBJDIR)/$(@B).obj $(@B).cpp
$(FREEZE): ..\common\win32\$(@B).cpp $(HEADERS)
@$(CC) $(CFLAGS) $(DEFINES) -c -Fo$(OBJDIR)/$(@B).obj ..\common\win32\$(@B).cpp
$(HELPOBJ): $(OBJDIR)/helptext.cpp
@$(CC) $(CFLAGS) $(DEFINES) -c -Fo$(OBJDIR)/helptext.obj $(OBJDIR)/helptext.cpp
$(OBJDIR)/helptext.cpp: manual.txt manual-*.txt
perl txt2c.pl > $(OBJDIR)/helptext.cpp

View File

@ -0,0 +1,181 @@
LDmicro is a ladder logic editor, simulator and compiler for 8-bit
microcontrollers. It can generate native code for Atmel AVR and Microchip
PIC16 CPUs from a ladder diagram.
This program is free software; see COPYING.txt.
I started work on LDmicro in October 2004.
At present, I receive a steady stream of questions and feature requests,
that I do not have time to address. I hope that others who find this
program interesting or useful may be able to complete this work.
BUILDING LDMICRO
================
LDmicro is built using the Microsoft Visual C++ compiler. If that is
installed correctly, then you should be able to just run
make.bat
and see everything build. The regression tests (however inadequate;
see below) will run automatically after the program is built.
Various source and header files are generated automatically. The perl
scripts to do this are included with this distribution, but it's necessary
to have a perl.exe in your path somewhere.
The makefile accepts an argument, D=LANG_XX, where XX is the language
code. make.bat supplies that argument automatically, as LANG_EN (English).
HIGH-LEVEL ARCHITECTURE
=======================
LDmicro is a compiler. Unlike typical compilers, it does not accept a text
file as its input; instead, the program is edited graphically, within
LDmicro itself. The editor represents the program as a tree structure,
where each node represents either an instruction (like relays contacts
or a coil) or a series or parallel subcircuit.
Based on this tree structure, intcode.cpp generates an intermediate
`instruction list' representation of the program. This intermediate code
is then passed to a processor-specific back-end, which generates code
for the target.
The program may also be simulated; in that case, rather than compiling
the intermediate code to a .hex file, we interpret the intermediate code
and display the results in real time.
The intermediate code is useful, because there are fewer intermediate
code ops than high-level ladder logic instructions.
See INTERNALS.txt for some discussion of LDmicro's internals.
POSSIBLE ENHANCEMENTS
=====================
If you are interested in contributing to LDmicro, then I believe that
the following work would be useful. The list is in ascending order
of difficulty.
* Better regression tests. There is a mechanism for this now (see the
reg/... directory), but very few tests. A regression test is just
an LDmicro program; I verify that the same input .ld file generates
the same output .hex file. The code generators are stupid enough
that these don't break all that often (no fancy optimizers that
reorder everything based on a small change to the input).
* Thorough tests of the existing microcontroller targets. This
requires appropriate hardware to test against. When I don't have
the hardware myself, I will sometimes test against a simulator,
but this is not as good as the real thing. The simulation of
peripherals is often approximate.
Even if no bugs are found, the test programs can become regression
tests, and we can mark those targets that have been tested as
`known good'.
* More targets for PIC16 and AVR architectures. In general, this
should be very easy; just add the appropriate entries in
mcutable.h. Some small changes to pic16.cpp or avr.cpp may be
required, if the peripheral registers move around.
I am not interested in new targets that have not been tested
against real hardware.
* The code generator has regression tests now. It would be nice to
also have regression tests for the display code. We could do this
using the "Export As Text" logic, since that calls the exact same
code that's used to display the program on-screen.
* Bitwise instructions that work on integers (e.g., let internal
relay Rfoo equal the seventh bit of integer variable x, set c =
a bitwise-and b, etc).
This would require new intermediate code ops, and thus changes to
both the PIC and AVR back ends, and thus testing of those changes.
Aside from that, it's very straightforward.
These new intcode ops could then be used by higher-level ELEM_XXX
ops, for example to do bit-banged synchronous serial protocols
(I2C, SPI), or to talk to an HD44780-type LCD.
* Intermediate code ops for look-up tables. At present, these are
implemented stupidly, as a chain of if-then statements. This would
require changes to all the code generators.
Look-up tables are important, not just for the `look-up table'
instruction, but also for the `formatted string over serial'
instruction, where the string is stored in a look-up table.
* New architecture targets. An architecture target translates from
LDmicro's intermediate code (intcode) to a binary for that
architecture. This means that it includes a code generator and
an assembler. The PIC16 and AVR targets are about 1500 lines of
code each.
A PIC18 target would be nice. I am not interested in a PIC18
back-end that does not exploit the additional addressing modes
and instructions (like rjmps); it would be easy to hack up the
PIC16 back end to generate something that would run on a PIC18,
but not useful.
An 8051 target is the other obvious choice, maybe also for the
MSP430.
* A Linux port. I am told that the current version runs perfectly
under WINE, but a native GTK port would be nice. That would be
a lot of work.
I am not interested in porting to a cross-platform GUI toolkit, and
thus abandoning the native Win32 user interface. In general, I think
that those toolkits end up looking equally wrong on all platforms.
If I were to undertake this myself, then I would probably end up
writing a miniature compatibility layer for the widgets that I
actually use, that mapped on to GTK under Linux and Win32 under
Windows, and so on. I've seen attempts at general-purpose libraries
to do that, but they look extremely complex for what they do.
In general, I am not interested in changes that involve linking against
non-standard libraries. (By non-standard, I mean anything that's not
distributed with the operating system.)
FOREIGN-LANGUAGE TRANSLATIONS
=============================
Foreign-language translations of the documentation and user interface
are always useful. At present, we have English, German, and French.
These do not require changes to the source code; a lookup table of
translated strings is automatically generated from lang-*.txt during
the build process. If you are interested in preparing a translation,
but do not wish to set up tools to build LDmicro, then just mail me the
lang-xx.txt, and I can build ldmicro-xx.exe for you.
At present, LDmicro does not use Unicode. This means that translations
into languages not written in the Latin alphabet are tricky. This could
be changed, of course.
FINAL
=====
I will always respond to bug reports. If LDmicro is behaving incorrectly
on some target, then please attach the simplest example of a program
that's misbehaving, and a description of the incorrect behavior.
Please contact me if you have any questions.
Jonathan Westhues
user jwesthues, at host cq.cx
near Seattle, Oct 21, 2007

View File

@ -0,0 +1 @@
path=%path%;c:\strawberry\c\bin;c:\strawberry\perl\site\bin;c:\strawberry\perl\bin;C:\Program Files\GnuWin32\bin

View File

@ -0,0 +1,431 @@
//-----------------------------------------------------------------------------
// 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/>.
//------
//
// Write the program as ANSI C source. This is very simple, because the
// intermediate code structure is really a lot like C. Someone else will be
// responsible for calling us with appropriate timing.
// Jonathan Westhues, Oct 2004
//-----------------------------------------------------------------------------
#include <windows.h>
#include <stdio.h>
#include <setjmp.h>
#include <stdlib.h>
#include "ldmicro.h"
#include "intcode.h"
static char SeenVariables[MAX_IO][MAX_NAME_LEN];
int SeenVariablesCount;
//-----------------------------------------------------------------------------
// Have we seen a variable before? If not then no need to generate code for
// it, otherwise we will have to make a declaration, and mark it as seen.
//-----------------------------------------------------------------------------
static BOOL SeenVariable(char *name)
{
int i;
for(i = 0; i < SeenVariablesCount; i++) {
if(strcmp(SeenVariables[i], name)==0) {
return TRUE;
}
}
if(i >= MAX_IO) oops();
strcpy(SeenVariables[i], name);
SeenVariablesCount++;
return FALSE;
}
//-----------------------------------------------------------------------------
// Turn an internal symbol into a C name; only trick is that internal symbols
// use $ for symbols that the int code generator needed for itself, so map
// that into something okay for C.
//-----------------------------------------------------------------------------
#define ASBIT 1
#define ASINT 2
static char *MapSym(char *str, int how)
{
if(!str) return NULL;
static char AllRets[16][MAX_NAME_LEN+30];
static int RetCnt;
RetCnt = (RetCnt + 1) & 15;
char *ret = AllRets[RetCnt];
// The namespace for bit and integer variables is distinct.
char bit_int;
if(how == ASBIT) {
bit_int = 'b';
} else if(how == ASINT) {
bit_int = 'i';
} else {
oops();
}
// User and internal symbols are distinguished.
if(*str == '$') {
sprintf(ret, "I_%c_%s", bit_int, str+1);
} else {
sprintf(ret, "U_%c_%s", bit_int, str);
}
return ret;
}
//-----------------------------------------------------------------------------
// Generate a declaration for an integer var; easy, a static 16-bit qty.
//-----------------------------------------------------------------------------
static void DeclareInt(FILE *f, char *str)
{
fprintf(f, "STATIC SWORD %s = 0;\n", str);
}
//-----------------------------------------------------------------------------
// Generate a declaration for a bit var; three cases, input, output, and
// internal relay. An internal relay is just a BOOL variable, but for an
// input or an output someone else must provide read/write functions.
//-----------------------------------------------------------------------------
static void DeclareBit(FILE *f, char *str)
{
// The mapped symbol has the form U_b_{X,Y,R}name, so look at character
// four to determine if it's an input, output, internal relay.
if(str[4] == 'X') {
fprintf(f, "\n");
fprintf(f, "/* You provide this function. */\n");
fprintf(f, "PROTO(extern BOOL Read_%s(void);)\n", str);
fprintf(f, "\n");
} else if(str[4] == 'Y') {
fprintf(f, "\n");
fprintf(f, "/* You provide these functions. */\n");
fprintf(f, "PROTO(BOOL Read_%s(void);)\n", str);
fprintf(f, "PROTO(void Write_%s(BOOL v);)\n", str);
fprintf(f, "\n");
} else {
fprintf(f, "STATIC BOOL %s = 0;\n", str);
fprintf(f, "#define Read_%s() %s\n", str, str);
fprintf(f, "#define Write_%s(x) %s = x\n", str, str);
}
}
//-----------------------------------------------------------------------------
// Generate declarations for all the 16-bit/single bit variables in the ladder
// program.
//-----------------------------------------------------------------------------
static void GenerateDeclarations(FILE *f)
{
int i;
for(i = 0; i < IntCodeLen; i++) {
char *bitVar1 = NULL, *bitVar2 = NULL;
char *intVar1 = NULL, *intVar2 = NULL, *intVar3 = NULL;
switch(IntCode[i].op) {
case INT_SET_BIT:
case INT_CLEAR_BIT:
bitVar1 = IntCode[i].name1;
break;
case INT_COPY_BIT_TO_BIT:
bitVar1 = IntCode[i].name1;
bitVar2 = IntCode[i].name2;
break;
case INT_SET_VARIABLE_TO_LITERAL:
intVar1 = IntCode[i].name1;
break;
case INT_SET_VARIABLE_TO_VARIABLE:
intVar1 = IntCode[i].name1;
intVar2 = IntCode[i].name2;
break;
case INT_SET_VARIABLE_DIVIDE:
case INT_SET_VARIABLE_MULTIPLY:
case INT_SET_VARIABLE_SUBTRACT:
case INT_SET_VARIABLE_ADD:
intVar1 = IntCode[i].name1;
intVar2 = IntCode[i].name2;
intVar3 = IntCode[i].name3;
break;
case INT_INCREMENT_VARIABLE:
case INT_READ_ADC:
case INT_SET_PWM:
intVar1 = IntCode[i].name1;
break;
case INT_UART_RECV:
case INT_UART_SEND:
intVar1 = IntCode[i].name1;
bitVar1 = IntCode[i].name2;
break;
case INT_IF_BIT_SET:
case INT_IF_BIT_CLEAR:
bitVar1 = IntCode[i].name1;
break;
case INT_IF_VARIABLE_LES_LITERAL:
intVar1 = IntCode[i].name1;
break;
case INT_IF_VARIABLE_EQUALS_VARIABLE:
case INT_IF_VARIABLE_GRT_VARIABLE:
intVar1 = IntCode[i].name1;
intVar2 = IntCode[i].name2;
break;
case INT_END_IF:
case INT_ELSE:
case INT_COMMENT:
case INT_SIMULATE_NODE_STATE:
case INT_EEPROM_BUSY_CHECK:
case INT_EEPROM_READ:
case INT_EEPROM_WRITE:
break;
default:
oops();
}
bitVar1 = MapSym(bitVar1, ASBIT);
bitVar2 = MapSym(bitVar2, ASBIT);
intVar1 = MapSym(intVar1, ASINT);
intVar2 = MapSym(intVar2, ASINT);
intVar3 = MapSym(intVar3, ASINT);
if(bitVar1 && !SeenVariable(bitVar1)) DeclareBit(f, bitVar1);
if(bitVar2 && !SeenVariable(bitVar2)) DeclareBit(f, bitVar2);
if(intVar1 && !SeenVariable(intVar1)) DeclareInt(f, intVar1);
if(intVar2 && !SeenVariable(intVar2)) DeclareInt(f, intVar2);
if(intVar3 && !SeenVariable(intVar3)) DeclareInt(f, intVar3);
}
}
//-----------------------------------------------------------------------------
// Actually generate the C source for the program.
//-----------------------------------------------------------------------------
static void GenerateAnsiC(FILE *f)
{
int i;
int indent = 1;
for(i = 0; i < IntCodeLen; i++) {
if(IntCode[i].op == INT_END_IF) indent--;
if(IntCode[i].op == INT_ELSE) indent--;
int j;
for(j = 0; j < indent; j++) fprintf(f, " ");
switch(IntCode[i].op) {
case INT_SET_BIT:
fprintf(f, "Write_%s(1);\n", MapSym(IntCode[i].name1, ASBIT));
break;
case INT_CLEAR_BIT:
fprintf(f, "Write_%s(0);\n", MapSym(IntCode[i].name1, ASBIT));
break;
case INT_COPY_BIT_TO_BIT:
fprintf(f, "Write_%s(Read_%s());\n",
MapSym(IntCode[i].name1, ASBIT),
MapSym(IntCode[i].name2, ASBIT));
break;
case INT_SET_VARIABLE_TO_LITERAL:
fprintf(f, "%s = %d;\n", MapSym(IntCode[i].name1, ASINT),
IntCode[i].literal);
break;
case INT_SET_VARIABLE_TO_VARIABLE:
fprintf(f, "%s = %s;\n", MapSym(IntCode[i].name1, ASINT),
MapSym(IntCode[i].name2, ASINT));
break;
{
char op;
case INT_SET_VARIABLE_ADD: op = '+'; goto arith;
case INT_SET_VARIABLE_SUBTRACT: op = '-'; goto arith;
case INT_SET_VARIABLE_MULTIPLY: op = '*'; goto arith;
case INT_SET_VARIABLE_DIVIDE: op = '/'; goto arith;
arith:
fprintf(f, "%s = %s %c %s;\n",
MapSym(IntCode[i].name1, ASINT),
MapSym(IntCode[i].name2, ASINT),
op,
MapSym(IntCode[i].name3, ASINT) );
break;
}
case INT_INCREMENT_VARIABLE:
fprintf(f, "%s++;\n", MapSym(IntCode[i].name1, ASINT));
break;
case INT_IF_BIT_SET:
fprintf(f, "if(Read_%s()) {\n",
MapSym(IntCode[i].name1, ASBIT));
indent++;
break;
case INT_IF_BIT_CLEAR:
fprintf(f, "if(!Read_%s()) {\n",
MapSym(IntCode[i].name1, ASBIT));
indent++;
break;
case INT_IF_VARIABLE_LES_LITERAL:
fprintf(f, "if(%s < %d) {\n", MapSym(IntCode[i].name1, ASINT),
IntCode[i].literal);
indent++;
break;
case INT_IF_VARIABLE_EQUALS_VARIABLE:
fprintf(f, "if(%s == %s) {\n", MapSym(IntCode[i].name1, ASINT),
MapSym(IntCode[i].name2, ASINT));
indent++;
break;
case INT_IF_VARIABLE_GRT_VARIABLE:
fprintf(f, "if(%s > %s) {\n", MapSym(IntCode[i].name1, ASINT),
MapSym(IntCode[i].name2, ASINT));
indent++;
break;
case INT_END_IF:
fprintf(f, "}\n");
break;
case INT_ELSE:
fprintf(f, "} else {\n"); indent++;
break;
case INT_SIMULATE_NODE_STATE:
// simulation-only
fprintf(f, "\n");
break;
case INT_COMMENT:
if(IntCode[i].name1[0]) {
fprintf(f, "/* %s */\n", IntCode[i].name1);
} else {
fprintf(f, "\n");
}
break;
case INT_EEPROM_BUSY_CHECK:
case INT_EEPROM_READ:
case INT_EEPROM_WRITE:
case INT_READ_ADC:
case INT_SET_PWM:
case INT_UART_RECV:
case INT_UART_SEND:
Error(_("ANSI C target does not support peripherals "
"(UART, PWM, ADC, EEPROM). Skipping that instruction."));
break;
default:
oops();
}
}
}
void CompileAnsiC(char *dest)
{
SeenVariablesCount = 0;
FILE *f = fopen(dest, "w");
if(!f) {
Error(_("Couldn't open file '%s'"), dest);
return;
}
fprintf(f,
"/* This is auto-generated code from LDmicro. Do not edit this file! Go\n"
" back to the ladder diagram source for changes in the logic, and make\n"
" any C additions either in ladder.h or in additional .c files linked\n"
" against this one. */\n"
"\n"
"/* You must provide ladder.h; there you must provide:\n"
" * a typedef for SWORD and BOOL, signed 16 bit and boolean types\n"
" (probably typedef signed short SWORD; typedef unsigned char BOOL;)\n"
"\n"
" You must also provide implementations of all the I/O read/write\n"
" either as inlines in the header file or in another source file. (The\n"
" I/O functions are all declared extern.)\n"
"\n"
" See the generated source code (below) for function names. */\n"
"#include \"ladder.h\"\n"
"\n"
"/* Define EXTERN_EVERYTHING in ladder.h if you want all symbols extern.\n"
" This could be useful to implement `magic variables,' so that for\n"
" example when you write to the ladder variable duty_cycle, your PLC\n"
" runtime can look at the C variable U_duty_cycle and use that to set\n"
" the PWM duty cycle on the micro. That way you can add support for\n"
" peripherals that LDmicro doesn't know about. */\n"
"#ifdef EXTERN_EVERYTHING\n"
"#define STATIC \n"
"#else\n"
"#define STATIC static\n"
"#endif\n"
"\n"
"/* Define NO_PROTOTYPES if you don't want LDmicro to provide prototypes for\n"
" all the I/O functions (Read_U_xxx, Write_U_xxx) that you must provide.\n"
" If you define this then you must provide your own prototypes for these\n"
" functions in ladder.h, or provide definitions (e.g. as inlines or macros)\n"
" for them in ladder.h. */\n"
"#ifdef NO_PROTOTYPES\n"
"#define PROTO(x)\n"
"#else\n"
"#define PROTO(x) x\n"
"#endif\n"
"\n"
"/* U_xxx symbols correspond to user-defined names. There is such a symbol\n"
" for every internal relay, variable, timer, and so on in the ladder\n"
" program. I_xxx symbols are internally generated. */\n"
);
// now generate declarations for all variables
GenerateDeclarations(f);
fprintf(f,
"\n"
"\n"
"/* Call this function once per PLC cycle. You are responsible for calling\n"
" it at the interval that you specified in the MCU configuration when you\n"
" generated this code. */\n"
"void PlcCycle(void)\n"
"{\n"
);
GenerateAnsiC(f);
fprintf(f, "}\n");
fclose(f);
char str[MAX_PATH+500];
sprintf(str, _("Please wait until OpenPLC Ladder compiles your code and send it to the PLC"));
/*
sprintf(str, _("Compile successful; wrote C source code to '%s'.\r\n\r\n"
"This 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."), dest);
*/
//CompileSuccessfulMessage(str);
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,950 @@
//-----------------------------------------------------------------------------
// 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/>.
//------
//
// Routines for modifying the circuit: add a particular element at a
// particular point, delete the selected element, etc.
// Jonathan Westhues, Oct 2004
//-----------------------------------------------------------------------------
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include "ldmicro.h"
static ElemSubcktSeries *LoadSeriesFromFile(FILE *f);
//-----------------------------------------------------------------------------
// Convenience routines for allocating frequently-used data structures.
//-----------------------------------------------------------------------------
ElemLeaf *AllocLeaf(void)
{
return (ElemLeaf *)CheckMalloc(sizeof(ElemLeaf));
}
ElemSubcktSeries *AllocSubcktSeries(void)
{
return (ElemSubcktSeries *)CheckMalloc(sizeof(ElemSubcktSeries));
}
ElemSubcktParallel *AllocSubcktParallel(void)
{
return (ElemSubcktParallel *)CheckMalloc(sizeof(ElemSubcktParallel));
}
//-----------------------------------------------------------------------------
// Routine that does the actual work of adding a leaf element to the left/
// right of or above/below the selected element. If we are adding left/right
// in a series circuit then it's easy; just increase length of that
// subcircuit and stick it in. Same goes for above/below in a parallel
// subcircuit. If we are adding above/below in a series circuit or left/right
// in a parallel circuit then we must create a new parallel (for series) or
// series (for parallel) subcircuit with 2 elements, one for the previously
// selected element and one for the new element. Calls itself recursively on
// all subcircuits. Returns TRUE if it or a child made the addition.
//-----------------------------------------------------------------------------
static BOOL AddLeafWorker(int which, void *any, int newWhich, ElemLeaf *newElem)
{
int i;
switch(which) {
case ELEM_SERIES_SUBCKT: {
ElemSubcktSeries *s = (ElemSubcktSeries *)any;
for(i = 0; i < s->count; i++) {
if(s->contents[i].d.any == Selected) {
break;
}
if(s->contents[i].which == ELEM_PARALLEL_SUBCKT) {
if(AddLeafWorker(ELEM_PARALLEL_SUBCKT, s->contents[i].d.any,
newWhich, newElem))
{
return TRUE;
}
}
}
if(i == s->count) break;
if(s->contents[i].which == ELEM_PLACEHOLDER) {
// Special case--placeholders are replaced. They only appear
// in the empty series subcircuit that I generate for them,
// so there is no need to consider them anywhere but here.
// If we copy instead of replacing then the DisplayMatrix
// tables don't get all messed up.
memcpy(s->contents[i].d.leaf, newElem, sizeof(ElemLeaf));
s->contents[i].d.leaf->selectedState = SELECTED_LEFT;
CheckFree(newElem);
s->contents[i].which = newWhich;
SelectedWhich = newWhich;
return TRUE;
}
if(s->count >= (MAX_ELEMENTS_IN_SUBCKT-1)) {
Error(_("Too many elements in subcircuit!"));
return TRUE;
}
switch(Selected->selectedState) {
case SELECTED_LEFT:
memmove(&s->contents[i+1], &s->contents[i],
(s->count - i)*sizeof(s->contents[0]));
s->contents[i].d.leaf = newElem;
s->contents[i].which = newWhich;
(s->count)++;
break;
case SELECTED_RIGHT:
memmove(&s->contents[i+2], &s->contents[i+1],
(s->count - i - 1)*sizeof(s->contents[0]));
s->contents[i+1].d.leaf = newElem;
s->contents[i+1].which = newWhich;
(s->count)++;
break;
case SELECTED_BELOW:
case SELECTED_ABOVE: {
ElemSubcktParallel *p = AllocSubcktParallel();
p->count = 2;
int t;
t = (Selected->selectedState == SELECTED_ABOVE) ? 0 : 1;
p->contents[t].which = newWhich;
p->contents[t].d.leaf = newElem;
t = (Selected->selectedState == SELECTED_ABOVE) ? 1 : 0;
p->contents[t].which = s->contents[i].which;
p->contents[t].d.any = s->contents[i].d.any;
s->contents[i].which = ELEM_PARALLEL_SUBCKT;
s->contents[i].d.parallel = p;
break;
}
default:
oops();
break;
}
return TRUE;
break;
}
case ELEM_PARALLEL_SUBCKT: {
ElemSubcktParallel *p = (ElemSubcktParallel *)any;
for(i = 0; i < p->count; i++) {
if(p->contents[i].d.any == Selected) {
break;
}
if(p->contents[i].which == ELEM_SERIES_SUBCKT) {
if(AddLeafWorker(ELEM_SERIES_SUBCKT, p->contents[i].d.any,
newWhich, newElem))
{
return TRUE;
}
}
}
if(i == p->count) break;
if(p->count >= (MAX_ELEMENTS_IN_SUBCKT-1)) {
Error(_("Too many elements in subcircuit!"));
return TRUE;
}
switch(Selected->selectedState) {
case SELECTED_ABOVE:
memmove(&p->contents[i+1], &p->contents[i],
(p->count - i)*sizeof(p->contents[0]));
p->contents[i].d.leaf = newElem;
p->contents[i].which = newWhich;
(p->count)++;
break;
case SELECTED_BELOW:
memmove(&p->contents[i+2], &p->contents[i+1],
(p->count - i - 1)*sizeof(p->contents[0]));
p->contents[i+1].d.leaf = newElem;
p->contents[i+1].which = newWhich;
(p->count)++;
break;
case SELECTED_LEFT:
case SELECTED_RIGHT: {
ElemSubcktSeries *s = AllocSubcktSeries();
s->count = 2;
int t;
t = (Selected->selectedState == SELECTED_LEFT) ? 0 : 1;
s->contents[t].which = newWhich;
s->contents[t].d.leaf = newElem;
t = (Selected->selectedState == SELECTED_LEFT) ? 1 : 0;
s->contents[t].which = p->contents[i].which;
s->contents[t].d.any = p->contents[i].d.any;
p->contents[i].which = ELEM_SERIES_SUBCKT;
p->contents[i].d.series = s;
break;
}
default:
oops();
break;
}
return TRUE;
break;
}
}
return FALSE;
}
//-----------------------------------------------------------------------------
// Add the specified leaf node in the position indicated by the cursor. We
// will search through the entire program using AddLeafWorker to find the
// insertion point, and AddLeafWorker will stick it in at the requested
// location and return TRUE. We return TRUE if it worked, else FALSE.
//-----------------------------------------------------------------------------
static BOOL AddLeaf(int newWhich, ElemLeaf *newElem)
{
if(!Selected || Selected->selectedState == SELECTED_NONE) return FALSE;
int i;
for(i = 0; i < Prog.numRungs; i++) {
if(AddLeafWorker(ELEM_SERIES_SUBCKT, Prog.rungs[i], newWhich, newElem))
{
WhatCanWeDoFromCursorAndTopology();
return TRUE;
}
}
return FALSE;
}
//-----------------------------------------------------------------------------
// Routines to allocate memory for a new circuit element (contact, coil, etc.)
// and insert it into the current program with AddLeaf. Fill in some default
// parameters, name etc. when we create the leaf; user can change them later.
//-----------------------------------------------------------------------------
void AddComment(char *str)
{
if(!CanInsertComment) return;
ElemLeaf *c = AllocLeaf();
strcpy(c->d.comment.str, str);
AddLeaf(ELEM_COMMENT, c);
}
void AddContact(void)
{
if(!CanInsertOther) return;
ElemLeaf *c = AllocLeaf();
strcpy(c->d.contacts.name, "Xnew");
c->d.contacts.negated = FALSE;
AddLeaf(ELEM_CONTACTS, c);
}
void AddCoil(void)
{
if(!CanInsertEnd) return;
ElemLeaf *c = AllocLeaf();
strcpy(c->d.coil.name, "Ynew");
c->d.coil.negated = FALSE;
c->d.coil.setOnly = FALSE;
c->d.coil.resetOnly = FALSE;
AddLeaf(ELEM_COIL, c);
}
void AddTimer(int which)
{
if(!CanInsertOther) return;
ElemLeaf *t = AllocLeaf();
strcpy(t->d.timer.name, "Tnew");
t->d.timer.delay = 100000;
AddLeaf(which, t);
}
void AddEmpty(int which)
{
if(!CanInsertOther) return;
ElemLeaf *t = AllocLeaf();
AddLeaf(which, t);
}
void AddReset(void)
{
if(!CanInsertEnd) return;
ElemLeaf *t = AllocLeaf();
strcpy(t->d.reset.name, "Tnew");
AddLeaf(ELEM_RES, t);
}
void AddMasterRelay(void)
{
if(!CanInsertEnd) return;
ElemLeaf *t = AllocLeaf();
AddLeaf(ELEM_MASTER_RELAY, t);
}
void AddShiftRegister(void)
{
if(!CanInsertEnd) return;
ElemLeaf *t = AllocLeaf();
strcpy(t->d.shiftRegister.name, "reg");
t->d.shiftRegister.stages = 7;
AddLeaf(ELEM_SHIFT_REGISTER, t);
}
void AddFormattedString(void)
{
if(!CanInsertOther) return;
ElemLeaf *t = AllocLeaf();
strcpy(t->d.fmtdStr.var, "var");
strcpy(t->d.fmtdStr.string, "value: \\3\\r\\n");
AddLeaf(ELEM_FORMATTED_STRING, t);
}
void AddLookUpTable(void)
{
if(!CanInsertEnd) return;
ElemLeaf *t = AllocLeaf();
strcpy(t->d.lookUpTable.dest, "dest");
strcpy(t->d.lookUpTable.index, "index");
t->d.lookUpTable.count = 0;
t->d.lookUpTable.editAsString = 0;
AddLeaf(ELEM_LOOK_UP_TABLE, t);
}
void AddPiecewiseLinear(void)
{
if(!CanInsertEnd) return;
ElemLeaf *t = AllocLeaf();
strcpy(t->d.piecewiseLinear.dest, "yvar");
strcpy(t->d.piecewiseLinear.index, "xvar");
t->d.piecewiseLinear.count = 0;
AddLeaf(ELEM_PIECEWISE_LINEAR, t);
}
void AddMove(void)
{
if(!CanInsertEnd) return;
ElemLeaf *t = AllocLeaf();
strcpy(t->d.move.dest, "dest");
strcpy(t->d.move.src, "src");
AddLeaf(ELEM_MOVE, t);
}
void AddMath(int which)
{
if(!CanInsertEnd) return;
ElemLeaf *t = AllocLeaf();
strcpy(t->d.math.dest, "dest");
strcpy(t->d.math.op1, "src");
strcpy(t->d.math.op2, "1");
AddLeaf(which, t);
}
void AddCmp(int which)
{
if(!CanInsertOther) return;
ElemLeaf *t = AllocLeaf();
strcpy(t->d.cmp.op1, "var");
strcpy(t->d.cmp.op2, "1");
AddLeaf(which, t);
}
void AddCounter(int which)
{
if(which == ELEM_CTC) {
if(!CanInsertEnd) return;
} else {
if(!CanInsertOther) return;
}
ElemLeaf *t = AllocLeaf();
strcpy(t->d.counter.name, "Cnew");
t->d.counter.max = 0;
AddLeaf(which, t);
}
void AddReadAdc(void)
{
if(!CanInsertEnd) return;
ElemLeaf *t = AllocLeaf();
strcpy(t->d.readAdc.name, "Anew");
AddLeaf(ELEM_READ_ADC, t);
}
void AddSetPwm(void)
{
if(!CanInsertEnd) return;
ElemLeaf *t = AllocLeaf();
strcpy(t->d.setPwm.name, "duty_cycle");
t->d.setPwm.targetFreq = 1000;
AddLeaf(ELEM_SET_PWM, t);
}
void AddUart(int which)
{
if(!CanInsertOther) return;
ElemLeaf *t = AllocLeaf();
strcpy(t->d.uart.name, "char");
AddLeaf(which, t);
}
void AddPersist(void)
{
if(!CanInsertEnd) return;
ElemLeaf *t = AllocLeaf();
strcpy(t->d.persist.var, "saved");
AddLeaf(ELEM_PERSIST, t);
}
//-----------------------------------------------------------------------------
// Any subcircuit containing only one element should be collapsed into its
// parent. Call ourselves recursively to do this on every child of the passed
// subcircuit. The passed subcircuit will not be collapsed itself, so that
// the rung subcircuit may contain only one element as a special case. Returns
// TRUE if it or a child made any changes, and for completeness must be
// called iteratively on the root till it doesn't do anything.
//-----------------------------------------------------------------------------
static BOOL CollapseUnnecessarySubckts(int which, void *any)
{
BOOL modified = FALSE;
ok();
switch(which) {
case ELEM_SERIES_SUBCKT: {
ElemSubcktSeries *s = (ElemSubcktSeries *)any;
int i;
for(i = 0; i < s->count; i++) {
if(s->contents[i].which == ELEM_PARALLEL_SUBCKT) {
ElemSubcktParallel *p = s->contents[i].d.parallel;
if(p->count == 1) {
if(p->contents[0].which == ELEM_SERIES_SUBCKT) {
// merge the two series subcircuits
ElemSubcktSeries *s2 = p->contents[0].d.series;
int makeSpaces = s2->count - 1;
memmove(&s->contents[i+makeSpaces+1],
&s->contents[i+1],
(s->count - i - 1)*sizeof(s->contents[0]));
memcpy(&s->contents[i], &s2->contents[0],
(s2->count)*sizeof(s->contents[0]));
s->count += makeSpaces;
CheckFree(s2);
} else {
s->contents[i].which = p->contents[0].which;
s->contents[i].d.any = p->contents[0].d.any;
}
CheckFree(p);
modified = TRUE;
} else {
if(CollapseUnnecessarySubckts(ELEM_PARALLEL_SUBCKT,
s->contents[i].d.parallel))
{
modified = TRUE;
}
}
}
// else a leaf, not a problem
}
break;
}
case ELEM_PARALLEL_SUBCKT: {
ElemSubcktParallel *p = (ElemSubcktParallel *)any;
int i;
for(i = 0; i < p->count; i++) {
if(p->contents[i].which == ELEM_SERIES_SUBCKT) {
ElemSubcktSeries *s = p->contents[i].d.series;
if(s->count == 1) {
if(s->contents[0].which == ELEM_PARALLEL_SUBCKT) {
// merge the two parallel subcircuits
ElemSubcktParallel *p2 = s->contents[0].d.parallel;
int makeSpaces = p2->count - 1;
memmove(&p->contents[i+makeSpaces+1],
&p->contents[i+1],
(p->count - i - 1)*sizeof(p->contents[0]));
memcpy(&p->contents[i], &p2->contents[0],
(p2->count)*sizeof(p->contents[0]));
p->count += makeSpaces;
CheckFree(p2);
} else {
p->contents[i].which = s->contents[0].which;
p->contents[i].d.any = s->contents[0].d.any;
}
CheckFree(s);
modified = TRUE;
} else {
if(CollapseUnnecessarySubckts(ELEM_SERIES_SUBCKT,
p->contents[i].d.series))
{
modified = TRUE;
}
}
}
// else a leaf, not a problem
}
break;
}
default:
oops();
break;
}
ok();
return modified;
}
//-----------------------------------------------------------------------------
// Delete the selected leaf element from the circuit. Just pull it out of the
// subcircuit that it was in before, and don't worry about creating
// subcircuits with only one element; we will clean that up later in a second
// pass. Returns TRUE if it or a child (calls self recursively) found and
// removed the element.
//-----------------------------------------------------------------------------
static BOOL DeleteSelectedFromSubckt(int which, void *any)
{
ok();
switch(which) {
case ELEM_SERIES_SUBCKT: {
ElemSubcktSeries *s = (ElemSubcktSeries *)any;
int i;
for(i = 0; i < s->count; i++) {
if(s->contents[i].d.any == Selected) {
ForgetFromGrid(s->contents[i].d.any);
CheckFree(s->contents[i].d.any);
memmove(&s->contents[i], &s->contents[i+1],
(s->count - i - 1)*sizeof(s->contents[0]));
(s->count)--;
return TRUE;
}
if(s->contents[i].which == ELEM_PARALLEL_SUBCKT) {
if(DeleteSelectedFromSubckt(ELEM_PARALLEL_SUBCKT,
s->contents[i].d.any))
{
return TRUE;
}
}
}
break;
}
case ELEM_PARALLEL_SUBCKT: {
ElemSubcktParallel *p = (ElemSubcktParallel *)any;
int i;
for(i = 0; i < p->count; i++) {
if(p->contents[i].d.any == Selected) {
ForgetFromGrid(p->contents[i].d.any);
CheckFree(p->contents[i].d.any);
memmove(&p->contents[i], &p->contents[i+1],
(p->count - i - 1)*sizeof(p->contents[0]));
(p->count)--;
return TRUE;
}
if(p->contents[i].which == ELEM_SERIES_SUBCKT) {
if(DeleteSelectedFromSubckt(ELEM_SERIES_SUBCKT,
p->contents[i].d.any))
{
return TRUE;
}
}
}
break;
}
default:
oops();
break;
}
return FALSE;
}
//-----------------------------------------------------------------------------
// Delete the selected item from the program. Just call
// DeleteSelectedFromSubckt on every rung till we find it.
//-----------------------------------------------------------------------------
void DeleteSelectedFromProgram(void)
{
if(!Selected || Selected->selectedState == SELECTED_NONE) return;
int i = RungContainingSelected();
if(i < 0) return;
if(Prog.rungs[i]->count == 1 &&
Prog.rungs[i]->contents[0].which != ELEM_PARALLEL_SUBCKT)
{
Prog.rungs[i]->contents[0].which = ELEM_PLACEHOLDER;
SelectedWhich = ELEM_PLACEHOLDER;
Selected->selectedState = SELECTED_LEFT;
WhatCanWeDoFromCursorAndTopology();
return;
}
int gx, gy;
if(!FindSelected(&gx, &gy)) {
gx = 0;
gy = 0;
}
if(DeleteSelectedFromSubckt(ELEM_SERIES_SUBCKT, Prog.rungs[i])) {
while(CollapseUnnecessarySubckts(ELEM_SERIES_SUBCKT, Prog.rungs[i]))
;
WhatCanWeDoFromCursorAndTopology();
MoveCursorNear(gx, gy);
return;
}
}
//-----------------------------------------------------------------------------
// Free a circuit and all of its subcircuits. Calls self recursively to do
// so.
//-----------------------------------------------------------------------------
void FreeCircuit(int which, void *any)
{
ok();
switch(which) {
case ELEM_SERIES_SUBCKT: {
ElemSubcktSeries *s = (ElemSubcktSeries *)any;
int i;
for(i = 0; i < s->count; i++) {
FreeCircuit(s->contents[i].which, s->contents[i].d.any);
}
CheckFree(s);
break;
}
case ELEM_PARALLEL_SUBCKT: {
ElemSubcktParallel *p = (ElemSubcktParallel *)any;
int i;
for(i = 0; i < p->count; i++) {
FreeCircuit(p->contents[i].which, p->contents[i].d.any);
}
CheckFree(p);
break;
}
CASE_LEAF
ForgetFromGrid(any);
CheckFree(any);
break;
default:
oops();
break;
}
ok();
}
//-----------------------------------------------------------------------------
// Free the entire program.
//-----------------------------------------------------------------------------
void FreeEntireProgram(void)
{
ForgetEverything();
int i;
for(i = 0; i < Prog.numRungs; i++) {
FreeCircuit(ELEM_SERIES_SUBCKT, Prog.rungs[i]);
}
Prog.numRungs = 0;
Prog.cycleTime = 10000;
Prog.mcuClock = 4000000;
Prog.baudRate = 2400;
Prog.io.count = 0;
Prog.mcu = NULL;
}
//-----------------------------------------------------------------------------
// Returns true if the given subcircuit contains the given leaf.
//-----------------------------------------------------------------------------
static BOOL ContainsElem(int which, void *any, ElemLeaf *seek)
{
switch(which) {
case ELEM_SERIES_SUBCKT: {
ElemSubcktSeries *s = (ElemSubcktSeries *)any;
int i;
for(i = 0; i < s->count; i++) {
if(ContainsElem(s->contents[i].which, s->contents[i].d.any,
seek))
{
return TRUE;
}
}
break;
}
case ELEM_PARALLEL_SUBCKT: {
ElemSubcktParallel *p = (ElemSubcktParallel *)any;
int i;
for(i = 0; i < p->count; i++) {
if(ContainsElem(p->contents[i].which, p->contents[i].d.any,
seek))
{
return TRUE;
}
}
break;
}
CASE_LEAF
if(any == seek)
return TRUE;
break;
default:
oops();
}
return FALSE;
}
//-----------------------------------------------------------------------------
// Use ContainsElem to find the rung containing the cursor.
//-----------------------------------------------------------------------------
int RungContainingSelected(void)
{
int i;
for(i = 0; i < Prog.numRungs; i++) {
if(ContainsElem(ELEM_SERIES_SUBCKT, Prog.rungs[i], Selected)) {
return i;
}
}
return -1;
}
//-----------------------------------------------------------------------------
// Delete the rung that contains the cursor.
//-----------------------------------------------------------------------------
void DeleteSelectedRung(void)
{
if(Prog.numRungs == 1) {
Error(_("Cannot delete rung; program must have at least one rung."));
return;
}
int gx, gy;
BOOL foundCursor;
foundCursor = FindSelected(&gx, &gy);
int i = RungContainingSelected();
if(i < 0) return;
FreeCircuit(ELEM_SERIES_SUBCKT, Prog.rungs[i]);
Prog.numRungs--;
memmove(&Prog.rungs[i], &Prog.rungs[i+1],
(Prog.numRungs - i)*sizeof(Prog.rungs[0]));
if(foundCursor) MoveCursorNear(gx, gy);
WhatCanWeDoFromCursorAndTopology();
}
//-----------------------------------------------------------------------------
// Allocate a new `empty' rung, with only a single relay coil at the end. All
// the UI code assumes that rungs always have a coil in them, so it would
// add a lot of nasty special cases to create rungs totally empty.
//-----------------------------------------------------------------------------
static ElemSubcktSeries *AllocEmptyRung(void)
{
ElemSubcktSeries *s = AllocSubcktSeries();
s->count = 1;
s->contents[0].which = ELEM_PLACEHOLDER;
ElemLeaf *l = AllocLeaf();
s->contents[0].d.leaf = l;
return s;
}
//-----------------------------------------------------------------------------
// Insert a rung either before or after the rung that contains the cursor.
//-----------------------------------------------------------------------------
void InsertRung(BOOL afterCursor)
{
if(Prog.numRungs >= (MAX_RUNGS - 1)) {
Error(_("Too many rungs!"));
return;
}
int i = RungContainingSelected();
if(i < 0) return;
if(afterCursor) i++;
memmove(&Prog.rungs[i+1], &Prog.rungs[i],
(Prog.numRungs - i)*sizeof(Prog.rungs[0]));
Prog.rungs[i] = AllocEmptyRung();
(Prog.numRungs)++;
WhatCanWeDoFromCursorAndTopology();
}
//-----------------------------------------------------------------------------
// Swap the row containing the selected element with the one under it, or do
// nothing if the rung is the last in the program.
//-----------------------------------------------------------------------------
void PushRungDown(void)
{
int i = RungContainingSelected();
if(i == (Prog.numRungs-1)) return;
ElemSubcktSeries *temp = Prog.rungs[i];
Prog.rungs[i] = Prog.rungs[i+1];
Prog.rungs[i+1] = temp;
WhatCanWeDoFromCursorAndTopology();
ScrollSelectedIntoViewAfterNextPaint = TRUE;
}
//-----------------------------------------------------------------------------
// Swap the row containing the selected element with the one above it, or do
// nothing if the rung is the last in the program.
//-----------------------------------------------------------------------------
void PushRungUp(void)
{
int i = RungContainingSelected();
if(i == 0) return;
ElemSubcktSeries *temp = Prog.rungs[i];
Prog.rungs[i] = Prog.rungs[i-1];
Prog.rungs[i-1] = temp;
WhatCanWeDoFromCursorAndTopology();
ScrollSelectedIntoViewAfterNextPaint = TRUE;
}
//-----------------------------------------------------------------------------
// Start a new project. Give them one rung, with a coil (that they can
// never delete) and nothing else.
//-----------------------------------------------------------------------------
void NewProgram(void)
{
UndoFlush();
FreeEntireProgram();
Prog.numRungs = 1;
Prog.rungs[0] = AllocEmptyRung();
}
//-----------------------------------------------------------------------------
// Worker for ItemIsLastInCircuit. Basically we look for seek in the given
// circuit, trying to see whether it occupies the last position in a series
// subcircuit (which may be in a parallel subcircuit that is in the last
// position of a series subcircuit that may be in a parallel subcircuit that
// etc.)
//-----------------------------------------------------------------------------
static void LastInCircuit(int which, void *any, ElemLeaf *seek,
BOOL *found, BOOL *andItemAfter)
{
switch(which) {
case ELEM_PARALLEL_SUBCKT: {
ElemSubcktParallel *p = (ElemSubcktParallel *)any;
int i;
for(i = 0; i < p->count; i++) {
LastInCircuit(p->contents[i].which, p->contents[i].d.any, seek,
found, andItemAfter);
if(*found) return;
}
break;
}
case ELEM_SERIES_SUBCKT: {
ElemSubcktSeries *s = (ElemSubcktSeries *)any;
LastInCircuit(s->contents[s->count-1].which,
s->contents[s->count-1].d.any, seek, found, andItemAfter);
break;
}
default:
if(*found) *andItemAfter = TRUE;
if(any == seek) *found = TRUE;
break;
}
}
//-----------------------------------------------------------------------------
// Is an item the last one in the circuit (i.e. does one of its terminals go
// to the rightmost bus bar)? We need to know this because that is the only
// circumstance in which it is okay to insert a coil, RES, etc. after
// something
//-----------------------------------------------------------------------------
BOOL ItemIsLastInCircuit(ElemLeaf *item)
{
int i = RungContainingSelected();
if(i < 0) return FALSE;
BOOL found = FALSE;
BOOL andItemAfter = FALSE;
LastInCircuit(ELEM_SERIES_SUBCKT, Prog.rungs[i], item, &found,
&andItemAfter);
if(found) return !andItemAfter;
return FALSE;
}
//-----------------------------------------------------------------------------
// Returns TRUE if the subcircuit contains any of the given instruction
// types (ELEM_....), else FALSE.
//-----------------------------------------------------------------------------
static BOOL ContainsWhich(int which, void *any, int seek1, int seek2, int seek3)
{
switch(which) {
case ELEM_PARALLEL_SUBCKT: {
ElemSubcktParallel *p = (ElemSubcktParallel *)any;
int i;
for(i = 0; i < p->count; i++) {
if(ContainsWhich(p->contents[i].which, p->contents[i].d.any,
seek1, seek2, seek3))
{
return TRUE;
}
}
break;
}
case ELEM_SERIES_SUBCKT: {
ElemSubcktSeries *s = (ElemSubcktSeries *)any;
int i;
for(i = 0; i < s->count; i++) {
if(ContainsWhich(s->contents[i].which, s->contents[i].d.any,
seek1, seek2, seek3))
{
return TRUE;
}
}
break;
}
default:
if(which == seek1 || which == seek2 || which == seek3) {
return TRUE;
}
break;
}
return FALSE;
}
//-----------------------------------------------------------------------------
// Are either of the UART functions (send or recv) used? Need to know this
// to know whether we must receive their pins.
//-----------------------------------------------------------------------------
BOOL UartFunctionUsed(void)
{
int i;
for(i = 0; i < Prog.numRungs; i++) {
if(ContainsWhich(ELEM_SERIES_SUBCKT, Prog.rungs[i],
ELEM_UART_RECV, ELEM_UART_SEND, ELEM_FORMATTED_STRING))
{
return TRUE;
}
}
return FALSE;
}
//-----------------------------------------------------------------------------
// Is the PWM function used? Need to know this to know whether we must reserve
// the pin.
//-----------------------------------------------------------------------------
BOOL PwmFunctionUsed(void)
{
int i;
for(i = 0; i < Prog.numRungs; i++) {
if(ContainsWhich(ELEM_SERIES_SUBCKT, Prog.rungs[i], ELEM_SET_PWM,
-1, -1))
{
return TRUE;
}
}
return FALSE;
}

View File

@ -0,0 +1,210 @@
//-----------------------------------------------------------------------------
// 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/>.
//------
//
// Dialog for setting the properties of a relay coils: negated or not,
// plus the name, plus set-only or reset-only
// Jonathan Westhues, Oct 2004
//-----------------------------------------------------------------------------
#include <windows.h>
#include <stdio.h>
#include <commctrl.h>
#include "ldmicro.h"
static HWND CoilDialog;
static HWND SourceInternalRelayRadio;
static HWND SourceMcuPinRadio;
static HWND NegatedRadio;
static HWND NormalRadio;
static HWND SetOnlyRadio;
static HWND ResetOnlyRadio;
static HWND NameTextbox;
static LONG_PTR PrevNameProc;
//-----------------------------------------------------------------------------
// 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;
}
}
return CallWindowProc((WNDPROC)PrevNameProc, hwnd, msg, wParam, lParam);
}
static void MakeControls(void)
{
HWND grouper = CreateWindowEx(0, WC_BUTTON, _("Type"),
WS_CHILD | BS_GROUPBOX | WS_VISIBLE | WS_TABSTOP,
7, 3, 120, 105, CoilDialog, NULL, Instance, NULL);
NiceFont(grouper);
NormalRadio = CreateWindowEx(0, WC_BUTTON, _("( ) Normal"),
WS_CHILD | BS_AUTORADIOBUTTON | WS_TABSTOP | WS_VISIBLE | WS_GROUP,
16, 21, 100, 20, CoilDialog, NULL, Instance, NULL);
NiceFont(NormalRadio);
NegatedRadio = CreateWindowEx(0, WC_BUTTON, _("(/) Negated"),
WS_CHILD | BS_AUTORADIOBUTTON | WS_TABSTOP | WS_VISIBLE,
16, 41, 100, 20, CoilDialog, NULL, Instance, NULL);
NiceFont(NegatedRadio);
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 grouper2 = CreateWindowEx(0, WC_BUTTON, _("Source"),
WS_CHILD | BS_GROUPBOX | WS_VISIBLE,
140, 3, 120, 65, CoilDialog, NULL, Instance, NULL);
NiceFont(grouper2);
SourceInternalRelayRadio = CreateWindowEx(0, WC_BUTTON, _("Internal Relay"),
WS_CHILD | BS_AUTORADIOBUTTON | WS_VISIBLE | WS_GROUP | WS_TABSTOP,
149, 21, 100, 20, CoilDialog, NULL, Instance, NULL);
NiceFont(SourceInternalRelayRadio);
SourceMcuPinRadio = CreateWindowEx(0, WC_BUTTON, _("Pin on MCU"),
WS_CHILD | BS_AUTORADIOBUTTON | WS_VISIBLE | WS_TABSTOP,
149, 41, 100, 20, CoilDialog, NULL, Instance, NULL);
NiceFont(SourceMcuPinRadio);
HWND textLabel = CreateWindowEx(0, WC_STATIC, _("Name:"),
WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SS_RIGHT,
135, 80, 50, 21, CoilDialog, NULL, Instance, NULL);
NiceFont(textLabel);
NameTextbox = CreateWindowEx(WS_EX_CLIENTEDGE, WC_EDIT, "",
WS_CHILD | ES_AUTOHSCROLL | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE,
190, 80, 155, 21, CoilDialog, NULL, Instance, NULL);
FixedFont(NameTextbox);
OkButton = CreateWindowEx(0, WC_BUTTON, _("OK"),
WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE | BS_DEFPUSHBUTTON,
276, 10, 70, 23, CoilDialog, NULL, Instance, NULL);
NiceFont(OkButton);
CancelButton = CreateWindowEx(0, WC_BUTTON, _("Cancel"),
WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE,
276, 40, 70, 23, CoilDialog, NULL, Instance, NULL);
NiceFont(CancelButton);
PrevNameProc = SetWindowLongPtr(NameTextbox, GWLP_WNDPROC,
(LONG_PTR)MyNameProc);
}
void ShowCoilDialog(BOOL *negated, BOOL *setOnly, BOOL *resetOnly, char *name)
{
CoilDialog = CreateWindowClient(0, "LDmicroDialog",
_("Coil"), WS_OVERLAPPED | WS_SYSMENU,
100, 100, 359, 115, NULL, NULL, Instance, NULL);
RECT r;
GetClientRect(CoilDialog, &r);
MakeControls();
if(name[0] == 'R') {
SendMessage(SourceInternalRelayRadio, BM_SETCHECK, BST_CHECKED, 0);
} else {
SendMessage(SourceMcuPinRadio, BM_SETCHECK, BST_CHECKED, 0);
}
SendMessage(NameTextbox, WM_SETTEXT, 0, (LPARAM)(name + 1));
if(*negated) {
SendMessage(NegatedRadio, BM_SETCHECK, BST_CHECKED, 0);
} else if(*setOnly) {
SendMessage(SetOnlyRadio, BM_SETCHECK, BST_CHECKED, 0);
} else if(*resetOnly) {
SendMessage(ResetOnlyRadio, BM_SETCHECK, BST_CHECKED, 0);
} else {
SendMessage(NormalRadio, BM_SETCHECK, BST_CHECKED, 0);
}
EnableWindow(MainWindow, FALSE);
ShowWindow(CoilDialog, TRUE);
SetFocus(NameTextbox);
SendMessage(NameTextbox, 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(CoilDialog, &msg)) continue;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
if(!DialogCancel) {
if(SendMessage(SourceInternalRelayRadio, BM_GETSTATE, 0, 0)
& BST_CHECKED)
{
name[0] = 'R';
} else {
name[0] = 'Y';
}
SendMessage(NameTextbox, WM_GETTEXT, (WPARAM)16, (LPARAM)(name+1));
if(SendMessage(NormalRadio, BM_GETSTATE, 0, 0) & BST_CHECKED) {
*negated = FALSE;
*setOnly = FALSE;
*resetOnly = FALSE;
} else if(SendMessage(NegatedRadio, BM_GETSTATE, 0, 0) & BST_CHECKED) {
*negated = TRUE;
*setOnly = FALSE;
*resetOnly = FALSE;
} else if(SendMessage(SetOnlyRadio, BM_GETSTATE, 0, 0) & BST_CHECKED) {
*negated = FALSE;
*setOnly = TRUE;
*resetOnly = FALSE;
} else if(SendMessage(ResetOnlyRadio, BM_GETSTATE, 0, 0) & BST_CHECKED)
{
*negated = FALSE;
*setOnly = FALSE;
*resetOnly = TRUE;
}
}
EnableWindow(MainWindow, TRUE);
DestroyWindow(CoilDialog);
return;
}

View File

@ -0,0 +1,97 @@
//-----------------------------------------------------------------------------
// 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/>.
//------
//
// Dialog to enter the text of a comment; make it long and skinny to
// encourage people to write it the way it will look on the diagram.
// Jonathan Westhues, Jun 2005
//-----------------------------------------------------------------------------
#include <windows.h>
#include <stdio.h>
#include <commctrl.h>
#include "ldmicro.h"
static HWND CommentDialog;
static HWND CommentTextbox;
static void MakeControls(void)
{
CommentTextbox = CreateWindowEx(WS_EX_CLIENTEDGE, WC_EDIT, "",
WS_CHILD | ES_AUTOHSCROLL | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE |
ES_MULTILINE | ES_WANTRETURN,
7, 10, 600, 38, CommentDialog, NULL, Instance, NULL);
FixedFont(CommentTextbox);
OkButton = CreateWindowEx(0, WC_BUTTON, _("OK"),
WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE | BS_DEFPUSHBUTTON,
620, 6, 70, 23, CommentDialog, NULL, Instance, NULL);
NiceFont(OkButton);
CancelButton = CreateWindowEx(0, WC_BUTTON, _("Cancel"),
WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE,
620, 36, 70, 23, CommentDialog, NULL, Instance, NULL);
NiceFont(CancelButton);
}
void ShowCommentDialog(char *comment)
{
CommentDialog = CreateWindowClient(0, "LDmicroDialog",
_("Comment"), WS_OVERLAPPED | WS_SYSMENU,
100, 100, 700, 65, NULL, NULL, Instance, NULL);
MakeControls();
SendMessage(CommentTextbox, WM_SETTEXT, 0, (LPARAM)comment);
EnableWindow(MainWindow, FALSE);
ShowWindow(CommentDialog, TRUE);
SetFocus(CommentTextbox);
SendMessage(CommentTextbox, 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_TAB && GetFocus() == CommentTextbox) {
SetFocus(OkButton);
continue;
} else if(msg.wParam == VK_ESCAPE) {
DialogDone = TRUE;
DialogCancel = TRUE;
break;
}
}
if(IsDialogMessage(CommentDialog, &msg)) continue;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
if(!DialogCancel) {
SendMessage(CommentTextbox, WM_GETTEXT, (WPARAM)(MAX_COMMENT_LEN-1),
(LPARAM)comment);
}
EnableWindow(MainWindow, TRUE);
DestroyWindow(CommentDialog);
return;
}

View File

@ -0,0 +1,373 @@
//-----------------------------------------------------------------------------
// 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/>.
//------
//
// Routines common to the code generators for all processor architectures.
// Jonathan Westhues, Nov 2004
//-----------------------------------------------------------------------------
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include "ldmicro.h"
// If we encounter an error while compiling then it's convenient to break
// out of the possibly-deeply-recursed function we're in.
jmp_buf CompileErrorBuf;
// Assignment of the internal relays to memory, efficient, one bit per
// relay.
static struct {
char name[MAX_NAME_LEN];
DWORD addr;
int bit;
BOOL assignedTo;
} InternalRelays[MAX_IO];
static int InternalRelayCount;
// Assignment of the `variables,' used for timers, counters, arithmetic, and
// other more general things. Allocate 2 octets (16 bits) per.
static struct {
char name[MAX_NAME_LEN];
DWORD addrl;
DWORD addrh;
} Variables[MAX_IO];
static int VariableCount;
#define NO_MEMORY 0xffffffff
static DWORD NextBitwiseAllocAddr;
static int NextBitwiseAllocBit;
static int MemOffset;
//-----------------------------------------------------------------------------
// Forget what memory has been allocated on the target, so we start from
// everything free.
//-----------------------------------------------------------------------------
void AllocStart(void)
{
NextBitwiseAllocAddr = NO_MEMORY;
MemOffset = 0;
InternalRelayCount = 0;
VariableCount = 0;
}
//-----------------------------------------------------------------------------
// Return the address of a previously unused octet of RAM on the target, or
// signal an error if there is no more available.
//-----------------------------------------------------------------------------
DWORD AllocOctetRam(void)
{
if(MemOffset >= Prog.mcu->ram[0].len) {
Error(_("Out of memory; simplify program or choose "
"microcontroller with more memory."));
CompileError();
}
MemOffset++;
return Prog.mcu->ram[0].start + MemOffset - 1;
}
//-----------------------------------------------------------------------------
// Return the address (octet address) and bit of a previously unused bit of
// RAM on the target.
//-----------------------------------------------------------------------------
void AllocBitRam(DWORD *addr, int *bit)
{
if(NextBitwiseAllocAddr != NO_MEMORY) {
*addr = NextBitwiseAllocAddr;
*bit = NextBitwiseAllocBit;
NextBitwiseAllocBit++;
if(NextBitwiseAllocBit > 7) {
NextBitwiseAllocAddr = NO_MEMORY;
}
return;
}
*addr = AllocOctetRam();
*bit = 0;
NextBitwiseAllocAddr = *addr;
NextBitwiseAllocBit = 1;
}
//-----------------------------------------------------------------------------
// Return the address (octet) and bit of the bit in memory that represents the
// given input or output pin. Raises an internal error if the specified name
// is not present in the I/O list or a user error if a pin has not been
// assigned to that I/O name. Will allocate if it no memory allocated for it
// yet, else will return the previously allocated bit.
//-----------------------------------------------------------------------------
static void MemForPin(char *name, DWORD *addr, int *bit, BOOL asInput)
{
int i;
for(i = 0; i < Prog.io.count; i++) {
if(strcmp(Prog.io.assignment[i].name, name)==0)
break;
}
if(i >= Prog.io.count) oops();
if(asInput && Prog.io.assignment[i].type == IO_TYPE_DIG_OUTPUT) oops();
if(!asInput && Prog.io.assignment[i].type == IO_TYPE_DIG_INPUT) oops();
int pin = Prog.io.assignment[i].pin;
for(i = 0; i < Prog.mcu->pinCount; i++) {
if(Prog.mcu->pinInfo[i].pin == pin)
break;
}
if(i >= Prog.mcu->pinCount) {
Error(_("Must assign pins for all I/O.\r\n\r\n"
"'%s' is not assigned."), name);
CompileError();
}
McuIoPinInfo *iop = &Prog.mcu->pinInfo[i];
if(asInput) {
*addr = Prog.mcu->inputRegs[iop->port - 'A'];
} else {
*addr = Prog.mcu->outputRegs[iop->port - 'A'];
}
*bit = iop->bit;
}
//-----------------------------------------------------------------------------
// Determine the mux register settings to read a particular ADC channel.
//-----------------------------------------------------------------------------
BYTE MuxForAdcVariable(char *name)
{
int i;
for(i = 0; i < Prog.io.count; i++) {
if(strcmp(Prog.io.assignment[i].name, name)==0)
break;
}
if(i >= Prog.io.count) oops();
int j;
for(j = 0; j < Prog.mcu->adcCount; j++) {
if(Prog.mcu->adcInfo[j].pin == Prog.io.assignment[i].pin) {
break;
}
}
if(j == Prog.mcu->adcCount) {
Error(_("Must assign pins for all ADC inputs (name '%s')."), name);
CompileError();
}
return Prog.mcu->adcInfo[j].muxRegValue;
}
//-----------------------------------------------------------------------------
// Allocate the two octets (16-bit count) for a variable, used for a variety
// of purposes.
//-----------------------------------------------------------------------------
void MemForVariable(char *name, DWORD *addrl, DWORD *addrh)
{
int i;
for(i = 0; i < VariableCount; i++) {
if(strcmp(name, Variables[i].name)==0) break;
}
if(i >= MAX_IO) {
Error(_("Internal limit exceeded (number of vars)"));
CompileError();
}
if(i == VariableCount) {
VariableCount++;
strcpy(Variables[i].name, name);
Variables[i].addrl = AllocOctetRam();
Variables[i].addrh = AllocOctetRam();
}
*addrl = Variables[i].addrl;
*addrh = Variables[i].addrh;
}
//-----------------------------------------------------------------------------
// Allocate or retrieve the bit of memory assigned to an internal relay or
// other thing that requires a single bit of storage.
//-----------------------------------------------------------------------------
static void MemForBitInternal(char *name, DWORD *addr, int *bit, BOOL writeTo)
{
int i;
for(i = 0; i < InternalRelayCount; i++) {
if(strcmp(name, InternalRelays[i].name)==0)
break;
}
if(i >= MAX_IO) {
Error(_("Internal limit exceeded (number of vars)"));
CompileError();
}
if(i == InternalRelayCount) {
InternalRelayCount++;
strcpy(InternalRelays[i].name, name);
AllocBitRam(&InternalRelays[i].addr, &InternalRelays[i].bit);
InternalRelays[i].assignedTo = FALSE;
}
*addr = InternalRelays[i].addr;
*bit = InternalRelays[i].bit;
if(writeTo) {
InternalRelays[i].assignedTo = TRUE;
}
}
//-----------------------------------------------------------------------------
// Retrieve the bit to read to determine whether a set of contacts is open
// or closed. Contacts could be internal relay, output pin, or input pin,
// or one of the internal state variables ($xxx) from the int code generator.
//-----------------------------------------------------------------------------
void MemForSingleBit(char *name, BOOL forRead, DWORD *addr, int *bit)
{
switch(name[0]) {
case 'X':
if(!forRead) oops();
MemForPin(name, addr, bit, TRUE);
break;
case 'Y':
MemForPin(name, addr, bit, FALSE);
break;
case 'R':
case '$':
MemForBitInternal(name, addr, bit, !forRead);
break;
default:
oops();
break;
}
}
//-----------------------------------------------------------------------------
// Retrieve the bit to write to set the state of an output.
//-----------------------------------------------------------------------------
void MemForCoil(char *name, DWORD *addr, int *bit)
{
switch(name[0]) {
case 'Y':
MemForPin(name, addr, bit, FALSE);
break;
case 'R':
MemForBitInternal(name, addr, bit, TRUE);
break;
default:
oops();
break;
}
}
//-----------------------------------------------------------------------------
// Do any post-compilation sanity checks necessary.
//-----------------------------------------------------------------------------
void MemCheckForErrorsPostCompile(void)
{
int i;
for(i = 0; i < InternalRelayCount; i++) {
if(!InternalRelays[i].assignedTo) {
Error(
_("Internal relay '%s' never assigned; add its coil somewhere."),
InternalRelays[i].name);
CompileError();
}
}
}
//-----------------------------------------------------------------------------
// From the I/O list, determine which pins are inputs and which pins are
// outputs, and pack that in 8-bit format as we will need to write to the
// TRIS or DDR registers. ADC pins are neither inputs nor outputs.
//-----------------------------------------------------------------------------
void BuildDirectionRegisters(BYTE *isInput, BYTE *isOutput)
{
memset(isOutput, 0x00, MAX_IO_PORTS);
memset(isInput, 0x00, MAX_IO_PORTS);
BOOL usedUart = UartFunctionUsed();
BOOL usedPwm = PwmFunctionUsed();
int i;
for(i = 0; i < Prog.io.count; i++) {
int pin = Prog.io.assignment[i].pin;
if(Prog.io.assignment[i].type == IO_TYPE_DIG_OUTPUT ||
Prog.io.assignment[i].type == IO_TYPE_DIG_INPUT)
{
int j;
for(j = 0; j < Prog.mcu->pinCount; j++) {
McuIoPinInfo *iop = &Prog.mcu->pinInfo[j];
if(iop->pin == pin) {
if(Prog.io.assignment[i].type == IO_TYPE_DIG_INPUT) {
isInput[iop->port - 'A'] |= (1 << iop->bit);
} else {
isOutput[iop->port - 'A'] |= (1 << iop->bit);
}
break;
}
}
if(j >= Prog.mcu->pinCount) {
Error(_("Must assign pins for all I/O.\r\n\r\n"
"'%s' is not assigned."),
Prog.io.assignment[i].name);
CompileError();
}
if(usedUart &&
(pin == Prog.mcu->uartNeeds.rxPin ||
pin == Prog.mcu->uartNeeds.txPin))
{
Error(_("UART in use; pins %d and %d reserved for that."),
Prog.mcu->uartNeeds.rxPin, Prog.mcu->uartNeeds.txPin);
CompileError();
}
if(usedPwm && pin == Prog.mcu->pwmNeedsPin) {
Error(_("PWM in use; pin %d reserved for that."),
Prog.mcu->pwmNeedsPin);
CompileError();
}
}
}
}
//-----------------------------------------------------------------------------
// Display our boilerplate warning that the baud rate error is too high.
//-----------------------------------------------------------------------------
void ComplainAboutBaudRateError(int divisor, double actual, double err)
{
Error(_("UART baud rate generator: divisor=%d actual=%.4f for %.2f%% "
"error.\r\n"
"\r\n"
"This 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\n"
"Code will be generated anyways but serial may be "
"unreliable or completely broken."), divisor, actual, err);
}
//-----------------------------------------------------------------------------
// Display our boilerplate warning that the baud rate is too slow (making
// for an overflowed divisor).
//-----------------------------------------------------------------------------
void ComplainAboutBaudRateOverflow(void)
{
Error(_("UART baud rate generator: too slow, divisor overflows. "
"Use a slower crystal or a faster baud rate.\r\n"
"\r\n"
"Code will be generated anyways but serial will likely be "
"completely broken."));
}

View File

@ -0,0 +1,249 @@
//-----------------------------------------------------------------------------
// 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/>.
//------
//
// Dialog for setting the overall PLC parameters. Mostly this relates to
// timing; to set up the timers we need to know the desired cycle time,
// which is configurable, plus the MCU clock (i.e. crystal frequency).
// Jonathan Westhues, Nov 2004
//-----------------------------------------------------------------------------
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <commctrl.h>
#include "ldmicro.h"
static HWND ConfDialog;
static HWND CrystalTextbox;
static HWND CycleTextbox;
static HWND BaudTextbox;
static LONG_PTR PrevCrystalProc;
static LONG_PTR PrevCycleProc;
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();
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;
}

View File

@ -0,0 +1,177 @@
//-----------------------------------------------------------------------------
// 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/>.
//------
//
// Dialog for setting the properties of a set of contacts: negated or not,
// plus the name
// Jonathan Westhues, Oct 2004
//-----------------------------------------------------------------------------
#include <windows.h>
#include <stdio.h>
#include <commctrl.h>
#include "ldmicro.h"
static HWND ContactsDialog;
static HWND NegatedCheckbox;
static HWND SourceInternalRelayRadio;
static HWND SourceInputPinRadio;
static HWND SourceOutputPinRadio;
static HWND NameTextbox;
static LONG_PTR PrevNameProc;
//-----------------------------------------------------------------------------
// 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;
}
}
return CallWindowProc((WNDPROC)PrevNameProc, hwnd, msg, wParam, lParam);
}
static void MakeControls(void)
{
HWND grouper = CreateWindowEx(0, WC_BUTTON, _("Source"),
WS_CHILD | BS_GROUPBOX | WS_VISIBLE,
7, 3, 120, 85, ContactsDialog, NULL, Instance, NULL);
NiceFont(grouper);
SourceInternalRelayRadio = CreateWindowEx(0, WC_BUTTON, _("Internal Relay"),
WS_CHILD | BS_AUTORADIOBUTTON | WS_TABSTOP | WS_VISIBLE,
16, 21, 100, 20, ContactsDialog, NULL, Instance, NULL);
NiceFont(SourceInternalRelayRadio);
SourceInputPinRadio = CreateWindowEx(0, WC_BUTTON, _("Input pin"),
WS_CHILD | BS_AUTORADIOBUTTON | WS_TABSTOP | WS_VISIBLE,
16, 41, 100, 20, ContactsDialog, NULL, Instance, NULL);
NiceFont(SourceInputPinRadio);
SourceOutputPinRadio = CreateWindowEx(0, WC_BUTTON, _("Output pin"),
WS_CHILD | BS_AUTORADIOBUTTON | WS_TABSTOP | WS_VISIBLE,
16, 61, 100, 20, ContactsDialog, NULL, Instance, NULL);
NiceFont(SourceOutputPinRadio);
HWND textLabel = CreateWindowEx(0, WC_STATIC, _("Name:"),
WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | SS_RIGHT,
135, 16, 50, 21, ContactsDialog, NULL, Instance, NULL);
NiceFont(textLabel);
NameTextbox = CreateWindowEx(WS_EX_CLIENTEDGE, WC_EDIT, "",
WS_CHILD | ES_AUTOHSCROLL | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE,
190, 16, 115, 21, ContactsDialog, NULL, Instance, NULL);
FixedFont(NameTextbox);
NegatedCheckbox = CreateWindowEx(0, WC_BUTTON, _("|/| Negated"),
WS_CHILD | BS_AUTOCHECKBOX | WS_TABSTOP | WS_VISIBLE,
146, 44, 160, 20, ContactsDialog, NULL, Instance, NULL);
NiceFont(NegatedCheckbox);
OkButton = CreateWindowEx(0, WC_BUTTON, _("OK"),
WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE | BS_DEFPUSHBUTTON,
321, 10, 70, 23, ContactsDialog, NULL, Instance, NULL);
NiceFont(OkButton);
CancelButton = CreateWindowEx(0, WC_BUTTON, _("Cancel"),
WS_CHILD | WS_TABSTOP | WS_CLIPSIBLINGS | WS_VISIBLE,
321, 40, 70, 23, ContactsDialog, NULL, Instance, NULL);
NiceFont(CancelButton);
PrevNameProc = SetWindowLongPtr(NameTextbox, GWLP_WNDPROC,
(LONG_PTR)MyNameProc);
}
void ShowContactsDialog(BOOL *negated, char *name)
{
ContactsDialog = CreateWindowClient(0, "LDmicroDialog",
_("Contacts"), WS_OVERLAPPED | WS_SYSMENU,
100, 100, 404, 95, NULL, NULL, Instance, NULL);
MakeControls();
if(name[0] == 'R') {
SendMessage(SourceInternalRelayRadio, BM_SETCHECK, BST_CHECKED, 0);
} else if(name[0] == 'Y') {
SendMessage(SourceOutputPinRadio, BM_SETCHECK, BST_CHECKED, 0);
} else {
SendMessage(SourceInputPinRadio, BM_SETCHECK, BST_CHECKED, 0);
}
if(*negated) {
SendMessage(NegatedCheckbox, BM_SETCHECK, BST_CHECKED, 0);
}
SendMessage(NameTextbox, WM_SETTEXT, 0, (LPARAM)(name + 1));
EnableWindow(MainWindow, FALSE);
ShowWindow(ContactsDialog, TRUE);
SetFocus(NameTextbox);
SendMessage(NameTextbox, 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(ContactsDialog, &msg)) continue;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
if(!DialogCancel) {
if(SendMessage(NegatedCheckbox, BM_GETSTATE, 0, 0) & BST_CHECKED) {
*negated = TRUE;
} else {
*negated = FALSE;
}
if(SendMessage(SourceInternalRelayRadio, BM_GETSTATE, 0, 0)
& BST_CHECKED)
{
name[0] = 'R';
} else if(SendMessage(SourceInputPinRadio, BM_GETSTATE, 0, 0)
& BST_CHECKED)
{
name[0] = 'X';
} else {
name[0] = 'Y';
}
SendMessage(NameTextbox, WM_GETTEXT, (WPARAM)16, (LPARAM)(name+1));
}
EnableWindow(MainWindow, TRUE);
DestroyWindow(ContactsDialog);
return;
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,607 @@
//-----------------------------------------------------------------------------
// 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/>.
//------
//
// The two `output devices' for the drawing code: either the export as text
// stuff to write to a file, or all the routines concerned with drawing to
// the screen.
// Jonathan Westhues, Dec 2004
//-----------------------------------------------------------------------------
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include "ldmicro.h"
void (*DrawChars)(int, int, char *);
// After an undo all the memory addresses change but make an effort to put
// the cursor roughly where it should be.
int SelectedGxAfterNextPaint = -1;
int SelectedGyAfterNextPaint = -1;
// After pushing a rung up or down the position of that rung in the table
// changes, but the cursor should stay where it was.
BOOL ScrollSelectedIntoViewAfterNextPaint;
// Buffer that we write to when exporting (drawing) diagram to a text file.
// Dynamically allocated so that we're at least slightly efficient.
static char **ExportBuffer;
// The fonts that we will use to draw the ladder diagram: fixed width, one
// normal-weight, one bold.
HFONT FixedWidthFont;
HFONT FixedWidthFontBold;
// Different colour brushes for right and left buses in simulation, but same
// colour for both in edit mode; also for the backgrounds in simulation and
// edit modes.
static HBRUSH BusRightBus;
static HBRUSH BusLeftBrush;
static HBRUSH BusBrush;
static HBRUSH BgBrush;
static HBRUSH SimBgBrush;
// Parameters that determine our offset if we are scrolled
int ScrollXOffset;
int ScrollYOffset;
int ScrollXOffsetMax;
int ScrollYOffsetMax;
// Is the cursor currently drawn? We XOR it so this gets toggled.
static BOOL CursorDrawn;
// Colours with which to do syntax highlighting, configurable
SyntaxHighlightingColours HighlightColours;
#define X_RIGHT_PADDING 30
//-----------------------------------------------------------------------------
// Blink the cursor on the schematic; called by a Windows timer. We XOR
// draw it so just draw the same rectangle every time to show/erase the
// cursor. Cursor may be in one of four places in the selected leaf (top,
// bottom, left, right) but we don't care; just go from the coordinates
// computed when we drew the schematic in the paint procedure.
//-----------------------------------------------------------------------------
void CALLBACK BlinkCursor(HWND hwnd, UINT msg, UINT_PTR id, DWORD time)
{
if(GetFocus() != MainWindow && !CursorDrawn) return;
if(Cursor.left == 0) return;
PlcCursor c;
memcpy(&c, &Cursor, sizeof(c));
c.top -= ScrollYOffset*POS_HEIGHT*FONT_HEIGHT;
c.left -= ScrollXOffset;
if(c.top >= IoListTop) return;
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);
}
//-----------------------------------------------------------------------------
// Output a string to the screen at a particular location, in character-
// sized units.
//-----------------------------------------------------------------------------
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;
}
}
//-----------------------------------------------------------------------------
// Total number of columns that we can display in the given amount of
// window area. Need to leave some slop on the right for the scrollbar, of
// course.
//-----------------------------------------------------------------------------
int ScreenColsAvailable(void)
{
RECT r;
GetClientRect(MainWindow, &r);
return (r.right - (X_PADDING + X_RIGHT_PADDING)) / (POS_WIDTH*FONT_WIDTH);
}
//-----------------------------------------------------------------------------
// Total number of columns that we can display in the given amount of
// window area. Need to leave some slop on the right for the scrollbar, of
// course, and extra slop at the bottom for the horiz scrollbar if it is
// shown.
//-----------------------------------------------------------------------------
int ScreenRowsAvailable(void)
{
int adj;
if(ScrollXOffsetMax == 0) {
adj = 0;
} else {
adj = 18;
}
return (IoListTop - Y_PADDING - adj) / (POS_HEIGHT*FONT_HEIGHT);
}
//-----------------------------------------------------------------------------
// Paint the ladder logic program to the screen. Also figure out where the
// cursor should go and fill in coordinates for BlinkCursor. Not allowed to
// draw deeper than IoListTop, as we would run in to the I/O listbox.
//-----------------------------------------------------------------------------
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);
// 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;
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);
}
Hdc = paintDc;
ok();
}
//-----------------------------------------------------------------------------
// Set up the syntax highlighting colours, according to the currently selected
// scheme.
//-----------------------------------------------------------------------------
static void SetSyntaxHighlightingColours(void)
{
static const SyntaxHighlightingColours Schemes[] = {
{
RGB(0, 0, 0), // bg
RGB(255, 255, 225), // def
RGB(255, 110, 90), // selected
RGB(255, 150, 90), // op
RGB(255, 255, 100), // punct
RGB(255, 160, 160), // lit
RGB(120, 255, 130), // name
RGB(130, 130, 130), // rungNum
RGB(130, 130, 245), // comment
RGB(255, 255, 255), // bus
RGB(0, 0, 0), // simBg
RGB(130, 130, 130), // simRungNum
RGB(100, 130, 130), // simOff
RGB(255, 150, 150), // simOn
RGB(255, 150, 150), // simBusLeft
RGB(150, 150, 255), // simBusRight
},
};
memcpy(&HighlightColours, &Schemes[0], sizeof(Schemes[0]));
}
//-----------------------------------------------------------------------------
// Set up the stuff we'll need to draw our schematic diagram. Fonts, brushes,
// pens, etc.
//-----------------------------------------------------------------------------
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);
}
//-----------------------------------------------------------------------------
// DrawChars function, for drawing to the export buffer instead of to the
// screen.
//-----------------------------------------------------------------------------
static void DrawCharsToExportBuffer(int cx, int cy, char *str)
{
while(*str) {
if(*str >= 10) {
ExportBuffer[cy][cx] = *str;
cx++;
}
str++;
}
}
//-----------------------------------------------------------------------------
// Export a text drawing of the ladder logic program to a file.
//-----------------------------------------------------------------------------
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 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));
PlcProgramSingleIo *io = &Prog.io.assignment[i];
char *type = IoTypeToString(io->type);
char pin[MAX_NAME_LEN];
PinNumberForIo(pin, io);
sprintf(b, " | | %s\n",
pin);
memcpy(b+2, io->name, strlen(io->name));
memcpy(b+31, type, strlen(type));
fprintf(f, "%s", b);
}
fclose(f);
// we may have trashed the grid tables a bit; a repaint will fix that
InvalidateRect(MainWindow, NULL, FALSE);
}
//-----------------------------------------------------------------------------
// Determine the settings of the vertical and (if needed) horizontal
// scrollbars used to scroll our view of the program.
//-----------------------------------------------------------------------------
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;
}

View File

@ -0,0 +1,308 @@
//-----------------------------------------------------------------------------
// 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/>.
//------
//
// Window to show our internal help. Roll my own using a rich edit control so
// that I don't have to distribute a separate Windows Help or HTML file; the
// manual is compiled in to the exe. Do pretty syntax highlighting style
// colours.
// Jonathan Westhues, Dec 2004
//-----------------------------------------------------------------------------
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <commctrl.h>
#include <richedit.h>
#include "ldmicro.h"
extern char *HelpText[];
extern char *HelpTextDe[];
extern char *HelpTextFr[];
extern char *HelpTextTr[];
static char *AboutText[] = {
"",
"ABOUT LDMICRO",
"=============",
"",
"LDmicro is a ladder logic editor, simulator and compiler for 8-bit",
"microcontrollers. It can generate native code for Atmel AVR and Microchip",
"PIC16 CPUs from a ladder diagram.",
"",
"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/>.",
"",
"The source code for LDmicro is available at",
"",
" http://cq.cx/ladder.pl",
"",
"Copyright 2005-2010 Jonathan Westhues",
"Release 2.2, built " __TIME__ " " __DATE__ ".",
"",
"Email: user jwesthues, at host cq.cx",
"",
NULL
};
static char **Text[] = {
#if defined(LDLANG_EN) || \
defined(LDLANG_ES) || \
defined(LDLANG_IT) || \
defined(LDLANG_PT)
HelpText,
#elif defined(LDLANG_DE)
HelpTextDe,
#elif defined(LDLANG_FR)
HelpTextFr,
#elif defined(LDLANG_TR)
HelpTextTr,
#else
# error "Bad language"
#endif
// Let's always keep the about text in English.
AboutText
};
static HWND HelpDialog[2];
static HWND RichEdit[2];
static BOOL HelpWindowOpen[2];
static int TitleHeight;
#define RICH_EDIT_HEIGHT(h) \
((((h) - 3 + (FONT_HEIGHT/2)) / FONT_HEIGHT) * FONT_HEIGHT)
static void SizeRichEdit(int a)
{
RECT r;
GetClientRect(HelpDialog[a], &r);
SetWindowPos(RichEdit[a], HWND_TOP, 6, 3, r.right - 6,
RICH_EDIT_HEIGHT(r.bottom), 0);
}
static BOOL Resizing(RECT *r, int wParam)
{
BOOL touched = FALSE;
if(r->right - r->left < 650) {
int diff = 650 - (r->right - r->left);
if(wParam == WMSZ_RIGHT || wParam == WMSZ_TOPRIGHT ||
wParam == WMSZ_BOTTOMRIGHT)
{
r->right += diff;
} else {
r->left -= diff;
}
touched = TRUE;
}
if(!(wParam == WMSZ_LEFT || wParam == WMSZ_RIGHT)) {
int h = r->bottom - r->top - TitleHeight - 5;
if(RICH_EDIT_HEIGHT(h) != h) {
int diff = h - RICH_EDIT_HEIGHT(h);
if(wParam == WMSZ_TOP || wParam == WMSZ_TOPRIGHT ||
wParam == WMSZ_TOPLEFT)
{
r->top += diff;
} else {
r->bottom -= diff;
}
touched = TRUE;
}
}
return !touched;
}
static void MakeControls(int a)
{
HMODULE re = LoadLibrary("RichEd20.dll");
if(!re) oops();
RichEdit[a] = CreateWindowEx(0, RICHEDIT_CLASS,
"", WS_CHILD | WS_CLIPSIBLINGS | WS_VISIBLE | ES_READONLY |
ES_MULTILINE | WS_VSCROLL,
0, 0, 100, 100, HelpDialog[a], NULL, Instance, NULL);
SendMessage(RichEdit[a], WM_SETFONT, (WPARAM)FixedWidthFont, TRUE);
SendMessage(RichEdit[a], EM_SETBKGNDCOLOR, (WPARAM)0, RGB(0, 0, 0));
SizeRichEdit(a);
int i;
BOOL nextSubHead = FALSE;
for(i = 0; Text[a][i]; i++) {
char *s = Text[a][i];
CHARFORMAT cf;
cf.cbSize = sizeof(cf);
cf.dwMask = CFM_BOLD | CFM_COLOR;
cf.dwEffects = 0;
if((s[0] == '=') ||
(Text[a][i+1] && Text[a][i+1][0] == '='))
{
cf.crTextColor = RGB(255, 255, 110);
} else if(s[3] == '|' && s[4] == '|') {
cf.crTextColor = RGB(255, 110, 255);
} else if(s[0] == '>' || nextSubHead) {
// Need to make a copy because the strings we are passed aren't
// mutable.
char copy[1024];
if(strlen(s) >= sizeof(copy)) oops();
strcpy(copy, s);
int j;
for(j = 1; copy[j]; j++) {
if(copy[j] == ' ' && copy[j-1] == ' ')
break;
}
BOOL justHeading = (copy[j] == '\0');
copy[j] = '\0';
cf.crTextColor = RGB(110, 255, 110);
SendMessage(RichEdit[a], EM_SETCHARFORMAT, SCF_SELECTION,
(LPARAM)&cf);
SendMessage(RichEdit[a], EM_REPLACESEL, (WPARAM)FALSE,
(LPARAM)copy);
SendMessage(RichEdit[a], EM_SETSEL, (WPARAM)-1, (LPARAM)-1);
// Special case if there's nothing except title on the line
if(!justHeading) {
copy[j] = ' ';
}
s += j;
cf.crTextColor = RGB(255, 110, 255);
nextSubHead = !nextSubHead;
} else {
cf.crTextColor = RGB(255, 255, 255);
}
SendMessage(RichEdit[a], EM_SETCHARFORMAT, SCF_SELECTION, (LPARAM)&cf);
SendMessage(RichEdit[a], EM_REPLACESEL, (WPARAM)FALSE, (LPARAM)s);
SendMessage(RichEdit[a], EM_SETSEL, (WPARAM)-1, (LPARAM)-1);
if(Text[a][i+1]) {
SendMessage(RichEdit[a], EM_REPLACESEL, FALSE, (LPARAM)"\r\n");
SendMessage(RichEdit[a], EM_SETSEL, (WPARAM)-1, (LPARAM)-1);
}
}
SendMessage(RichEdit[a], EM_SETSEL, (WPARAM)0, (LPARAM)0);
}
//-----------------------------------------------------------------------------
// Window proc for the help dialog.
//-----------------------------------------------------------------------------
static LRESULT CALLBACK HelpProc(HWND hwnd, UINT msg, WPARAM wParam,
LPARAM lParam)
{
int a = (hwnd == HelpDialog[0] ? 0 : 1);
switch (msg) {
case WM_SIZING: {
RECT *r = (RECT *)lParam;
return Resizing(r, wParam);
break;
}
case WM_SIZE:
SizeRichEdit(a);
break;
case WM_ACTIVATE:
case WM_KEYDOWN:
SetFocus(RichEdit[a]);
break;
case WM_DESTROY:
case WM_CLOSE:
HelpWindowOpen[a] = FALSE;
// fall through
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
return 1;
}
//-----------------------------------------------------------------------------
// Create the class for the help window.
//-----------------------------------------------------------------------------
static void MakeClass(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)HelpProc;
wc.hInstance = Instance;
wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
wc.lpszClassName = "LDmicroHelp";
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);
}
void ShowHelpDialog(BOOL about)
{
int a = about ? 1 : 0;
if(HelpWindowOpen[a]) {
SetForegroundWindow(HelpDialog[a]);
return;
}
MakeClass();
char *s = about ? "About LDmicro" : "LDmicro Help";
HelpDialog[a] = CreateWindowEx(0, "LDmicroHelp", s,
WS_OVERLAPPED | WS_SYSMENU | WS_THICKFRAME | WS_MINIMIZEBOX |
WS_SIZEBOX,
100, 100, 650, 300+10*FONT_HEIGHT, NULL, NULL, Instance, NULL);
MakeControls(a);
ShowWindow(HelpDialog[a], TRUE);
SetFocus(RichEdit[a]);
HelpWindowOpen[a] = TRUE;
RECT r;
GetClientRect(HelpDialog[a], &r);
TitleHeight = 300 - r.bottom;
GetWindowRect(HelpDialog[a], &r);
Resizing(&r, WMSZ_TOP);
SetWindowPos(HelpDialog[a], HWND_TOP, r.left, r.top, r.right - r.left,
r.bottom - r.top, 0);
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,83 @@
//-----------------------------------------------------------------------------
// 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/>.
//------
//
// Description of the intermediate code that we generate. The routines in
// intcode.cpp generate this intermediate code from the program source. Then
// either we simulate the intermediate code with the routines in simulate.cpp
// or we convert it to PIC or AVR instructions so that it can run on a
// real device.
// Jonathan Westhues, Nov 2004
//-----------------------------------------------------------------------------
#ifndef __INTCODE_H
#define __INTCODE_H
#define INT_SET_BIT 1
#define INT_CLEAR_BIT 2
#define INT_COPY_BIT_TO_BIT 3
#define INT_SET_VARIABLE_TO_LITERAL 4
#define INT_SET_VARIABLE_TO_VARIABLE 5
#define INT_INCREMENT_VARIABLE 6
#define INT_SET_VARIABLE_ADD 7
#define INT_SET_VARIABLE_SUBTRACT 8
#define INT_SET_VARIABLE_MULTIPLY 9
#define INT_SET_VARIABLE_DIVIDE 10
#define INT_READ_ADC 11
#define INT_SET_PWM 12
#define INT_UART_SEND 13
#define INT_UART_RECV 14
#define INT_EEPROM_BUSY_CHECK 15
#define INT_EEPROM_READ 16
#define INT_EEPROM_WRITE 17
#define INT_IF_GROUP(x) (((x) >= 50) && ((x) < 60))
#define INT_IF_BIT_SET 50
#define INT_IF_BIT_CLEAR 51
#define INT_IF_VARIABLE_LES_LITERAL 52
#define INT_IF_VARIABLE_EQUALS_VARIABLE 53
#define INT_IF_VARIABLE_GRT_VARIABLE 54
#define INT_ELSE 60
#define INT_END_IF 61
#define INT_SIMULATE_NODE_STATE 80
#define INT_COMMENT 100
// Only used for the interpretable code.
#define INT_END_OF_PROGRAM 255
#if !defined(INTCODE_H_CONSTANTS_ONLY)
typedef struct IntOpTag {
int op;
char name1[MAX_NAME_LEN];
char name2[MAX_NAME_LEN];
char name3[MAX_NAME_LEN];
SWORD literal;
BOOL *poweredAfter;
} IntOp;
#define MAX_INT_OPS (1024*16)
extern IntOp IntCode[MAX_INT_OPS];
extern int IntCodeLen;
#endif
#endif

View File

@ -0,0 +1,248 @@
//-----------------------------------------------------------------------------
// 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/>.
//------
//
// A crunched-down version of the intermediate code (e.g. assigning addresses
// to all the variables instead of just working with their names), suitable
// for interpretation.
// Jonathan Westhues, Aug 2005
//-----------------------------------------------------------------------------
#include <windows.h>
#include <stdio.h>
#include <setjmp.h>
#include <stdlib.h>
#include "ldmicro.h"
#include "intcode.h"
static char Variables[MAX_IO][MAX_NAME_LEN];
static int VariablesCount;
static char InternalRelays[MAX_IO][MAX_NAME_LEN];
static int InternalRelaysCount;
typedef struct {
WORD op;
WORD name1;
WORD name2;
WORD name3;
SWORD literal;
} BinOp;
static BinOp OutProg[MAX_INT_OPS];
static WORD AddrForInternalRelay(char *name)
{
int i;
for(i = 0; i < InternalRelaysCount; i++) {
if(strcmp(InternalRelays[i], name)==0) {
return i;
}
}
strcpy(InternalRelays[i], name);
InternalRelaysCount++;
return i;
}
static WORD AddrForVariable(char *name)
{
int i;
for(i = 0; i < VariablesCount; i++) {
if(strcmp(Variables[i], name)==0) {
return i;
}
}
strcpy(Variables[i], name);
VariablesCount++;
return i;
}
static void Write(FILE *f, BinOp *op)
{
BYTE *b = (BYTE *)op;
int i;
for(i = 0; i < sizeof(*op); i++) {
fprintf(f, "%02x", b[i]);
}
fprintf(f, "\n");
}
void CompileInterpreted(char *outFile)
{
FILE *f = fopen(outFile, "w");
if(!f) {
Error(_("Couldn't write to '%s'"), outFile);
return;
}
InternalRelaysCount = 0;
VariablesCount = 0;
fprintf(f, "$$LDcode\n");
int ipc;
int outPc;
BinOp op;
// Convert the if/else structures in the intermediate code to absolute
// conditional jumps, to make life a bit easier for the interpreter.
#define MAX_IF_NESTING 32
int ifDepth = 0;
// PC for the if(...) instruction, which we will complete with the
// 'jump to if false' address (which is either the ELSE+1 or the ENDIF+1)
int ifOpIf[MAX_IF_NESTING];
// PC for the else instruction, which we will complete with the
// 'jump to if reached' address (which is the ENDIF+1)
int ifOpElse[MAX_IF_NESTING];
outPc = 0;
for(ipc = 0; ipc < IntCodeLen; ipc++) {
memset(&op, 0, sizeof(op));
op.op = IntCode[ipc].op;
switch(IntCode[ipc].op) {
case INT_CLEAR_BIT:
case INT_SET_BIT:
op.name1 = AddrForInternalRelay(IntCode[ipc].name1);
break;
case INT_COPY_BIT_TO_BIT:
op.name1 = AddrForInternalRelay(IntCode[ipc].name1);
op.name2 = AddrForInternalRelay(IntCode[ipc].name2);
break;
case INT_SET_VARIABLE_TO_LITERAL:
op.name1 = AddrForVariable(IntCode[ipc].name1);
op.literal = IntCode[ipc].literal;
break;
case INT_SET_VARIABLE_TO_VARIABLE:
op.name1 = AddrForVariable(IntCode[ipc].name1);
op.name2 = AddrForVariable(IntCode[ipc].name2);
break;
case INT_INCREMENT_VARIABLE:
op.name1 = AddrForVariable(IntCode[ipc].name1);
break;
case INT_SET_VARIABLE_ADD:
case INT_SET_VARIABLE_SUBTRACT:
case INT_SET_VARIABLE_MULTIPLY:
case INT_SET_VARIABLE_DIVIDE:
op.name1 = AddrForVariable(IntCode[ipc].name1);
op.name2 = AddrForVariable(IntCode[ipc].name2);
op.name3 = AddrForVariable(IntCode[ipc].name3);
break;
case INT_IF_BIT_SET:
case INT_IF_BIT_CLEAR:
op.name1 = AddrForInternalRelay(IntCode[ipc].name1);
goto finishIf;
case INT_IF_VARIABLE_LES_LITERAL:
op.name1 = AddrForVariable(IntCode[ipc].name1);
op.literal = IntCode[ipc].literal;
goto finishIf;
case INT_IF_VARIABLE_EQUALS_VARIABLE:
case INT_IF_VARIABLE_GRT_VARIABLE:
op.name1 = AddrForVariable(IntCode[ipc].name1);
op.name2 = AddrForVariable(IntCode[ipc].name2);
goto finishIf;
finishIf:
ifOpIf[ifDepth] = outPc;
ifOpElse[ifDepth] = 0;
ifDepth++;
// jump target will be filled in later
break;
case INT_ELSE:
ifOpElse[ifDepth-1] = outPc;
// jump target will be filled in later
break;
case INT_END_IF:
--ifDepth;
if(ifOpElse[ifDepth] == 0) {
// There is no else; if should jump straight to the
// instruction after this one if the condition is false.
OutProg[ifOpIf[ifDepth]].name3 = outPc-1;
} else {
// There is an else clause; if the if is false then jump
// just past the else, and if the else is reached then
// jump to the endif.
OutProg[ifOpIf[ifDepth]].name3 = ifOpElse[ifDepth];
OutProg[ifOpElse[ifDepth]].name3 = outPc-1;
}
// But don't generate an instruction for this.
continue;
case INT_SIMULATE_NODE_STATE:
case INT_COMMENT:
// Don't care; ignore, and don't generate an instruction.
continue;
case INT_EEPROM_BUSY_CHECK:
case INT_EEPROM_READ:
case INT_EEPROM_WRITE:
case INT_READ_ADC:
case INT_SET_PWM:
case INT_UART_SEND:
case INT_UART_RECV:
default:
Error(_("Unsupported op (anything ADC, PWM, UART, EEPROM) for "
"interpretable target."));
fclose(f);
return;
}
memcpy(&OutProg[outPc], &op, sizeof(op));
outPc++;
}
int i;
for(i = 0; i < outPc; i++) {
Write(f, &OutProg[i]);
}
memset(&op, 0, sizeof(op));
op.op = INT_END_OF_PROGRAM;
Write(f, &op);
fprintf(f, "$$bits\n");
for(i = 0; i < InternalRelaysCount; i++) {
if(InternalRelays[i][0] != '$') {
fprintf(f, "%s,%d\n", InternalRelays[i], i);
}
}
fprintf(f, "$$int16s\n");
for(i = 0; i < VariablesCount; i++) {
if(Variables[i][0] != '$') {
fprintf(f, "%s,%d\n", Variables[i], i);
}
}
fprintf(f, "$$cycle %d us\n", Prog.cycleTime);
fclose(f);
char str[MAX_PATH+500];
sprintf(str,
_("Compile successful; wrote interpretable code to '%s'.\r\n\r\n"
"You probably have to adapt the interpreter to your application. See "
"the documentation."), outFile);
CompileSuccessfulMessage(str);
}

View File

@ -0,0 +1,885 @@
//-----------------------------------------------------------------------------
// 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/>.
//------
//
// Routines to maintain the processor I/O list. Whenever the user changes the
// name of an element, rebuild the I/O list from the PLC program, so that new
// assigned names are automatically reflected in the I/O list. Also keep a
// list of old I/Os that have been deleted, so that if the user deletes a
// a name and then recreates it the associated settings (e.g. pin number)
// will not be forgotten. Also the dialog box for assigning I/O pins.
// Jonathan Westhues, Oct 2004
//-----------------------------------------------------------------------------
#include <windows.h>
#include <commctrl.h>
#include <stdio.h>
#include <stdlib.h>
#include "ldmicro.h"
// I/O that we have seen recently, so that we don't forget pin assignments
// when we re-extract the list
#define MAX_IO_SEEN_PREVIOUSLY 512
static struct {
char name[MAX_NAME_LEN];
int type;
int pin;
} 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;
static HWND IoDialog;
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;
//-----------------------------------------------------------------------------
// Append an I/O to the I/O list if it is not in there already.
//-----------------------------------------------------------------------------
static void AppendIo(char *name, int type)
{
int i;
for(i = 0; i < Prog.io.count; i++) {
if(strcmp(Prog.io.assignment[i].name, name)==0) {
if(type != IO_TYPE_GENERAL && Prog.io.assignment[i].type ==
IO_TYPE_GENERAL)
{
Prog.io.assignment[i].type = type;
}
// already in there
return;
}
}
if(i < MAX_IO) {
Prog.io.assignment[i].type = type;
Prog.io.assignment[i].pin = NO_PIN_ASSIGNED;
strcpy(Prog.io.assignment[i].name, name);
(Prog.io.count)++;
}
}
//-----------------------------------------------------------------------------
// Move an I/O pin into the `seen previously' list. This means that if the
// user creates input Xasd, assigns it a pin, deletes, and then recreates it,
// then it will come back with the correct pin assigned.
//-----------------------------------------------------------------------------
static void AppendIoSeenPreviously(char *name, int type, int pin)
{
if(strcmp(name+1, "new")==0) return;
int i;
for(i = 0; i < IoSeenPreviouslyCount; i++) {
if(strcmp(name, IoSeenPreviously[i].name)==0 &&
type == IoSeenPreviously[i].type)
{
if(pin != NO_PIN_ASSIGNED) {
IoSeenPreviously[i].pin = pin;
}
return;
}
}
if(IoSeenPreviouslyCount >= MAX_IO_SEEN_PREVIOUSLY) {
// maybe improve later; just throw away all our old information, and
// the user might have to reenter the pin if they delete and recreate
// things
IoSeenPreviouslyCount = 0;
}
i = IoSeenPreviouslyCount;
IoSeenPreviously[i].type = type;
IoSeenPreviously[i].pin = pin;
strcpy(IoSeenPreviously[i].name, name);
IoSeenPreviouslyCount++;
}
//-----------------------------------------------------------------------------
// Walk a subcircuit, calling ourselves recursively and extracting all the
// I/O names out of it.
//-----------------------------------------------------------------------------
static void ExtractNamesFromCircuit(int which, void *any)
{
ElemLeaf *l = (ElemLeaf *)any;
switch(which) {
case ELEM_PARALLEL_SUBCKT: {
ElemSubcktParallel *p = (ElemSubcktParallel *)any;
int i;
for(i = 0; i < p->count; i++) {
ExtractNamesFromCircuit(p->contents[i].which,
p->contents[i].d.any);
}
break;
}
case ELEM_SERIES_SUBCKT: {
ElemSubcktSeries *s = (ElemSubcktSeries *)any;
int i;
for(i = 0; i < s->count; i++) {
ExtractNamesFromCircuit(s->contents[i].which,
s->contents[i].d.any);
}
break;
}
case ELEM_CONTACTS:
switch(l->d.contacts.name[0]) {
case 'R':
AppendIo(l->d.contacts.name, IO_TYPE_INTERNAL_RELAY);
break;
case 'Y':
AppendIo(l->d.contacts.name, IO_TYPE_DIG_OUTPUT);
break;
case 'X':
AppendIo(l->d.contacts.name, IO_TYPE_DIG_INPUT);
break;
default:
oops();
break;
}
break;
case ELEM_COIL:
AppendIo(l->d.coil.name, l->d.coil.name[0] == 'R' ?
IO_TYPE_INTERNAL_RELAY : IO_TYPE_DIG_OUTPUT);
break;
case ELEM_TON:
case ELEM_TOF:
AppendIo(l->d.timer.name, which == ELEM_TON ? IO_TYPE_TON :
IO_TYPE_TOF);
break;
case ELEM_RTO:
AppendIo(l->d.timer.name, IO_TYPE_RTO);
break;
case ELEM_MOVE:
AppendIo(l->d.move.dest, IO_TYPE_GENERAL);
break;
case ELEM_ADD:
case ELEM_SUB:
case ELEM_MUL:
case ELEM_DIV:
AppendIo(l->d.math.dest, IO_TYPE_GENERAL);
break;
case ELEM_FORMATTED_STRING:
if(strlen(l->d.fmtdStr.var) > 0) {
AppendIo(l->d.fmtdStr.var, IO_TYPE_UART_TX);
}
break;
case ELEM_UART_SEND:
AppendIo(l->d.uart.name, IO_TYPE_UART_TX);
break;
case ELEM_UART_RECV:
AppendIo(l->d.uart.name, IO_TYPE_UART_RX);
break;
case ELEM_SET_PWM:
AppendIo(l->d.setPwm.name, IO_TYPE_PWM_OUTPUT);
break;
case ELEM_CTU:
case ELEM_CTD:
case ELEM_CTC:
AppendIo(l->d.counter.name, IO_TYPE_COUNTER);
break;
case ELEM_READ_ADC:
AppendIo(l->d.readAdc.name, IO_TYPE_READ_ADC);
break;
case ELEM_SHIFT_REGISTER: {
int i;
for(i = 0; i < l->d.shiftRegister.stages; i++) {
char str[MAX_NAME_LEN+10];
sprintf(str, "%s%d", l->d.shiftRegister.name, i);
AppendIo(str, IO_TYPE_GENERAL);
}
break;
}
case ELEM_LOOK_UP_TABLE:
AppendIo(l->d.lookUpTable.dest, IO_TYPE_GENERAL);
break;
case ELEM_PIECEWISE_LINEAR:
AppendIo(l->d.piecewiseLinear.dest, IO_TYPE_GENERAL);
break;
case ELEM_PLACEHOLDER:
case ELEM_COMMENT:
case ELEM_SHORT:
case ELEM_OPEN:
case ELEM_MASTER_RELAY:
case ELEM_ONE_SHOT_RISING:
case ELEM_ONE_SHOT_FALLING:
case ELEM_EQU:
case ELEM_NEQ:
case ELEM_GRT:
case ELEM_GEQ:
case ELEM_LES:
case ELEM_LEQ:
case ELEM_RES:
case ELEM_PERSIST:
break;
default:
oops();
}
}
//-----------------------------------------------------------------------------
// Compare function to qsort() the I/O list. Group by type, then
// alphabetically within each section.
//-----------------------------------------------------------------------------
static int CompareIo(const void *av, const void *bv)
{
PlcProgramSingleIo *a = (PlcProgramSingleIo *)av;
PlcProgramSingleIo *b = (PlcProgramSingleIo *)bv;
if(a->type != b->type) {
return a->type - b->type;
}
if(a->pin == NO_PIN_ASSIGNED && b->pin != NO_PIN_ASSIGNED) return 1;
if(b->pin == NO_PIN_ASSIGNED && a->pin != NO_PIN_ASSIGNED) return -1;
return strcmp(a->name, b->name);
}
//-----------------------------------------------------------------------------
// Wipe the I/O list and then re-extract it from the PLC program, taking
// care not to forget the pin assignments. Gets passed the selected item
// as an index into the list; modifies the list, so returns the new selected
// item as an index into the new list.
//-----------------------------------------------------------------------------
int GenerateIoList(int prevSel)
{
int i, j;
char selName[MAX_NAME_LEN];
if(prevSel >= 0) {
strcpy(selName, Prog.io.assignment[prevSel].name);
}
if(IoSeenPreviouslyCount > MAX_IO_SEEN_PREVIOUSLY/2) {
// flush it so there's lots of room, and we don't run out and
// forget important things
IoSeenPreviouslyCount = 0;
}
// remember the pin assignments
for(i = 0; i < Prog.io.count; i++) {
AppendIoSeenPreviously(Prog.io.assignment[i].name,
Prog.io.assignment[i].type, Prog.io.assignment[i].pin);
}
// wipe the list
Prog.io.count = 0;
// extract the new list so that it must be up to date
for(i = 0; i < Prog.numRungs; i++) {
ExtractNamesFromCircuit(ELEM_SERIES_SUBCKT, Prog.rungs[i]);
}
for(i = 0; i < Prog.io.count; i++) {
if(Prog.io.assignment[i].type == IO_TYPE_DIG_INPUT ||
Prog.io.assignment[i].type == IO_TYPE_DIG_OUTPUT ||
Prog.io.assignment[i].type == IO_TYPE_READ_ADC)
{
for(j = 0; j < IoSeenPreviouslyCount; j++) {
if(strcmp(Prog.io.assignment[i].name,
IoSeenPreviously[j].name)==0)
{
Prog.io.assignment[i].pin = IoSeenPreviously[j].pin;
break;
}
}
}
}
qsort(Prog.io.assignment, Prog.io.count, sizeof(PlcProgramSingleIo),
CompareIo);
if(prevSel >= 0) {
for(i = 0; i < Prog.io.count; i++) {
if(strcmp(Prog.io.assignment[i].name, selName)==0)
break;
}
if(i < Prog.io.count)
return i;
}
// no previous, or selected was deleted
return -1;
}
//-----------------------------------------------------------------------------
// Load the I/O list from a file. Since we are just loading pin assignments,
// put it into IoSeenPreviously so that it will get used on the next
// extraction.
//-----------------------------------------------------------------------------
BOOL LoadIoListFromFile(FILE *f)
{
char line[80];
char name[MAX_NAME_LEN];
int pin;
while(fgets(line, sizeof(line), f)) {
if(strcmp(line, "END\n")==0) {
return TRUE;
}
// Don't internationalize this! It's the file format, not UI.
if(sscanf(line, " %s at %d", name, &pin)==2) {
int type;
switch(name[0]) {
case 'X': type = IO_TYPE_DIG_INPUT; break;
case 'Y': type = IO_TYPE_DIG_OUTPUT; break;
case 'A': type = IO_TYPE_READ_ADC; break;
default: oops();
}
AppendIoSeenPreviously(name, type, pin);
}
}
return FALSE;
}
//-----------------------------------------------------------------------------
// Write the I/O list to a file. Since everything except the pin assignment
// can be extracted from the schematic, just write the Xs and Ys.
//-----------------------------------------------------------------------------
void SaveIoListToFile(FILE *f)
{
int i;
for(i = 0; i < Prog.io.count; i++) {
if(Prog.io.assignment[i].type == IO_TYPE_DIG_INPUT ||
Prog.io.assignment[i].type == IO_TYPE_DIG_OUTPUT ||
Prog.io.assignment[i].type == IO_TYPE_READ_ADC)
{
// Don't internationalize this! It's the file format, not UI.
fprintf(f, " %s at %d\n", Prog.io.assignment[i].name,
Prog.io.assignment[i].pin);
}
}
}
//-----------------------------------------------------------------------------
// 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);
}
}
//-----------------------------------------------------------------------------
// 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;
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;
}
//-----------------------------------------------------------------------------
// 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;
}
//-----------------------------------------------------------------------------
// Called in response to a notify for the listview. Handles click, text-edit
// operations etc., but also gets called to find out what text to display
// 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;
}
}
}

View File

@ -0,0 +1,762 @@
"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/As 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"

View File

@ -0,0 +1,767 @@
"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"

View File

@ -0,0 +1,761 @@
"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"

View File

@ -0,0 +1,761 @@
"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"

View File

@ -0,0 +1,66 @@
#!/usr/bin/perl
$engl = 1;
while(<>) {
chomp;
if(/^\s*$/) {
if($engl) {
next;
} else {
die "blank line mid-translation at $file, $.\n";
}
}
if($engl) {
$toTranslate = $_;
$engl = 0;
} else {
$translated = $_;
$toTranslate =~ s/\0/\\"/g;
$toTranslate =~ s#"##g;
$Already{$toTranslate} = 1;
$engl = 1;
}
}
# A tool to generate a list of strings to internationalize
for $file (<*.cpp>) {
open(IN, $file) or die;
$source = join("", <IN>);
close IN;
$source =~ s/\\"/\0/g;
while($source =~ m#
_\( \s*
((
\s* "
[^"]+
" \s*
)+)
\s*\)
#xsg) {
$str = $1;
$strIn = '';
while($str =~ m#\s*"([^"]+)"\s*#g) {
$strIn .= $1;
}
$Occurs{$strIn} = $c++;
$String{$strIn}++;
}
}
sub by_occurrence {
$Occurs{$a} <=> $Occurs{$b};
}
for (sort by_occurrence (keys %String)) {
if (not $Already{$_}) {
$_ =~ s/\0/\\"/g;
print qq{"$_"\n\n\n};
}
}

View File

@ -0,0 +1,765 @@
"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"

View File

@ -0,0 +1,52 @@
#!/usr/bin/perl
$t = '';
for $file (sort <lang-*.txt>) {
open(IN, $file);
$name = $file;
$name =~ s#lang-##;
$name =~ s#(.)#uc($1)#e;
$name =~ s#\.txt##;
$nameUc = uc($name);
print "#ifdef LDLANG_$nameUc\n";
print "static LangTable Lang${name}Table[] = {\n";
$engl = 1;
$. = 0;
while(<IN>) {
chomp;
if(/^\s*$/) {
if($engl) {
next;
} else {
die "blank line mid-translation at $file, $.\n";
}
}
if($engl) {
$toTranslate = $_;
$engl = 0;
} else {
$translated = $_;
print " { $toTranslate, $translated },\n";
$engl = 1;
}
}
print "};\n";
print <<EOT;
static Lang Lang$name = {
Lang${name}Table, sizeof(Lang${name}Table)/sizeof(Lang${name}Table[0])
};
#endif
EOT
close FILE;
}

View File

@ -0,0 +1,761 @@
"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"

View File

@ -0,0 +1,78 @@
//-----------------------------------------------------------------------------
// 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/>.
//------
//
// Multiple language support. For every non-English language, we have a
// table that maps the English strings to the translated strings. An
// internationalized version of the program will attempt to translate any
// string that is passed, using the appropriate (selected by a #define)
// table. If it fails then it just returns the English.
// Jonathan Westhues, Apr 2007
//-----------------------------------------------------------------------------
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include "ldmicro.h"
typedef struct LangTableTag {
char *from;
char *to;
} LangTable;
typedef struct LangTag {
LangTable *tab;
int n;
} Lang;
// These are the actual translation tables, so should be included in just
// one place.
#include "obj/lang-tables.h"
char *_(char *in)
{
Lang *l;
#if defined(LDLANG_EN)
return in;
#elif defined(LDLANG_DE)
l = &LangDe;
#elif defined(LDLANG_FR)
l = &LangFr;
#elif defined(LDLANG_ES)
l = &LangEs;
#elif defined(LDLANG_IT)
l = &LangIt;
#elif defined(LDLANG_TR)
l = &LangTr;
#elif defined(LDLANG_PT)
l = &LangPt;
#else
# error "Unrecognized language!"
#endif
int i;
for(i = 0; i < l->n; i++) {
if(strcmp(in, l->tab[i].from)==0) {
return l->tab[i].to;
}
}
return in;
}

View File

@ -0,0 +1,380 @@
//-----------------------------------------------------------------------------
// A sample interpreter for the .int files generate by LDmicro. These files
// represent a ladder logic program for a simple 'virtual machine.' The
// interpreter must simulate the virtual machine and for proper timing the
// program must be run over and over, with the period specified when it was
// compiled (in Settings -> MCU Parameters).
//
// This method of running the ladder logic code would be useful if you wanted
// to embed a ladder logic interpreter inside another program. LDmicro has
// converted all variables into addresses, for speed of execution. However,
// the .int file includes the mapping between variable names (same names
// that the user specifies, that are visible on the ladder diagram) and
// addresses. You can use this to establish specially-named variables that
// define the interface between your ladder code and the rest of your program.
//
// In this example, I use this mechanism to print the value of the integer
// variable 'a' after every cycle, and to generate a square wave with period
// 2*Tcycle on the input 'Xosc'. That is only for demonstration purposes, of
// course.
//
// In a real application you would need some way to get the information in the
// .int file into your device; this would be very application-dependent. Then
// you would need something like the InterpretOneCycle() routine to actually
// run the code. You can redefine the program and data memory sizes to
// whatever you think is practical; there are no particular constraints.
//
// The disassembler is just for debugging, of course. Note the unintuitive
// names for the condition ops; the INT_IFs are backwards, and the INT_ELSE
// is actually an unconditional jump! This is because I reused the names
// from the intermediate code that LDmicro uses, in which the if/then/else
// constructs have not yet been resolved into (possibly conditional)
// absolute jumps. It makes a lot of sense to me, but probably not so much
// to you; oh well.
//
// Jonathan Westhues, Aug 2005
//-----------------------------------------------------------------------------
#include <stdio.h>
#include <ctype.h>
#include <windows.h>
#define INTCODE_H_CONSTANTS_ONLY
#include "intcode.h"
typedef unsigned char BYTE; // 8-bit unsigned
typedef unsigned short WORD; // 16-bit unsigned
typedef signed short SWORD; // 16-bit signed
// Some arbitrary limits on the program and data size
#define MAX_OPS 1024
#define MAX_VARIABLES 128
#define MAX_INTERNAL_RELAYS 128
// This data structure represents a single instruction for the 'virtual
// machine.' The .op field gives the opcode, and the other fields give
// arguments. I have defined all of these as 16-bit fields for generality,
// but if you want then you can crunch them down to 8-bit fields (and
// limit yourself to 256 of each type of variable, of course). If you
// crunch down .op then nothing bad happens at all. If you crunch down
// .literal then you only have 8-bit literals now (so you can't move
// 300 into 'var'). If you crunch down .name3 then that limits your code size,
// because that is the field used to encode the jump addresses.
//
// A more compact encoding is very possible if space is a problem for
// you. You will probably need some kind of translator regardless, though,
// to put it in whatever format you're going to pack in flash or whatever,
// and also to pick out the name <-> address mappings for those variables
// that you're going to use for your interface out. I will therefore leave
// that up to you.
typedef struct {
WORD op;
WORD name1;
WORD name2;
WORD name3;
SWORD literal;
} BinOp;
BinOp Program[MAX_OPS];
SWORD Integers[MAX_VARIABLES];
BYTE Bits[MAX_INTERNAL_RELAYS];
// This are addresses (indices into Integers[] or Bits[]) used so that your
// C code can get at some of the ladder variables, by remembering the
// mapping between some ladder names and their addresses.
int SpecialAddrForA;
int SpecialAddrForXosc;
//-----------------------------------------------------------------------------
// What follows are just routines to load the program, which I represent as
// hex bytes, one instruction per line, into memory. You don't need to
// remember the length of the program because the last instruction is a
// special marker (INT_END_OF_PROGRAM).
//
void BadFormat(void)
{
fprintf(stderr, "Bad program format.\n");
exit(-1);
}
int HexDigit(int c)
{
c = tolower(c);
if(isdigit(c)) {
return c - '0';
} else if(c >= 'a' && c <= 'f') {
return (c - 'a') + 10;
} else {
BadFormat();
}
return 0;
}
void LoadProgram(char *fileName)
{
int pc;
FILE *f = fopen(fileName, "r");
char line[80];
// This is not suitable for untrusted input.
if(!f) {
fprintf(stderr, "couldn't open '%s'\n", f);
exit(-1);
}
if(!fgets(line, sizeof(line), f)) BadFormat();
if(strcmp(line, "$$LDcode\n")!=0) BadFormat();
for(pc = 0; ; pc++) {
char *t, i;
BYTE *b;
if(!fgets(line, sizeof(line), f)) BadFormat();
if(strcmp(line, "$$bits\n")==0) break;
if(strlen(line) != sizeof(BinOp)*2 + 1) BadFormat();
t = line;
b = (BYTE *)&Program[pc];
for(i = 0; i < sizeof(BinOp); i++) {
b[i] = HexDigit(t[1]) | (HexDigit(t[0]) << 4);
t += 2;
}
}
SpecialAddrForA = -1;
SpecialAddrForXosc = -1;
while(fgets(line, sizeof(line), f)) {
if(memcmp(line, "a,", 2)==0) {
SpecialAddrForA = atoi(line+2);
}
if(memcmp(line, "Xosc,", 5)==0) {
SpecialAddrForXosc = atoi(line+5);
}
if(memcmp(line, "$$cycle", 7)==0) {
if(atoi(line + 7) != 10*1000) {
fprintf(stderr, "cycle time was not 10 ms when compiled; "
"please fix that.\n");
exit(-1);
}
}
}
if(SpecialAddrForA < 0 || SpecialAddrForXosc < 0) {
fprintf(stderr, "special interface variables 'a' or 'Xosc' not "
"used in prog.\n");
exit(-1);
}
fclose(f);
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Disassemble the program and pretty-print it. This is just for debugging,
// and it is also the only documentation for what each op does. The bit
// variables (internal relays or whatever) live in a separate space from the
// integer variables; I refer to those as bits[addr] and int16s[addr]
// respectively.
//-----------------------------------------------------------------------------
void Disassemble(void)
{
int pc;
for(pc = 0; ; pc++) {
BinOp *p = &Program[pc];
printf("%03x: ", pc);
switch(Program[pc].op) {
case INT_SET_BIT:
printf("bits[%03x] := 1", p->name1);
break;
case INT_CLEAR_BIT:
printf("bits[%03x] := 0", p->name1);
break;
case INT_COPY_BIT_TO_BIT:
printf("bits[%03x] := bits[%03x]", p->name1, p->name2);
break;
case INT_SET_VARIABLE_TO_LITERAL:
printf("int16s[%03x] := %d (0x%04x)", p->name1, p->literal,
p->literal);
break;
case INT_SET_VARIABLE_TO_VARIABLE:
printf("int16s[%03x] := int16s[%03x]", p->name1, p->name2);
break;
case INT_INCREMENT_VARIABLE:
printf("(int16s[%03x])++", p->name1);
break;
{
char c;
case INT_SET_VARIABLE_ADD: c = '+'; goto arith;
case INT_SET_VARIABLE_SUBTRACT: c = '-'; goto arith;
case INT_SET_VARIABLE_MULTIPLY: c = '*'; goto arith;
case INT_SET_VARIABLE_DIVIDE: c = '/'; goto arith;
arith:
printf("int16s[%03x] := int16s[%03x] %c int16s[%03x]",
p->name1, p->name2, c, p->name3);
break;
}
case INT_IF_BIT_SET:
printf("unless (bits[%03x] set)", p->name1);
goto cond;
case INT_IF_BIT_CLEAR:
printf("unless (bits[%03x] clear)", p->name1);
goto cond;
case INT_IF_VARIABLE_LES_LITERAL:
printf("unless (int16s[%03x] < %d)", p->name1, p->literal);
goto cond;
case INT_IF_VARIABLE_EQUALS_VARIABLE:
printf("unless (int16s[%03x] == int16s[%03x])", p->name1,
p->name2);
goto cond;
case INT_IF_VARIABLE_GRT_VARIABLE:
printf("unless (int16s[%03x] > int16s[%03x])", p->name1,
p->name2);
goto cond;
cond:
printf(" jump %03x+1", p->name3);
break;
case INT_ELSE:
printf("jump %03x+1", p->name3);
break;
case INT_END_OF_PROGRAM:
printf("<end of program>\n");
return;
default:
BadFormat();
break;
}
printf("\n");
}
}
//-----------------------------------------------------------------------------
// This is the actual interpreter. It runs the program, and needs no state
// other than that kept in Bits[] and Integers[]. If you specified a cycle
// time of 10 ms when you compiled the program, then you would have to
// call this function 100 times per second for the timing to be correct.
//
// The execution time of this function depends mostly on the length of the
// program. It will be a little bit data-dependent but not very.
//-----------------------------------------------------------------------------
void InterpretOneCycle(void)
{
int pc;
for(pc = 0; ; pc++) {
BinOp *p = &Program[pc];
switch(Program[pc].op) {
case INT_SET_BIT:
Bits[p->name1] = 1;
break;
case INT_CLEAR_BIT:
Bits[p->name1] = 0;
break;
case INT_COPY_BIT_TO_BIT:
Bits[p->name1] = Bits[p->name2];
break;
case INT_SET_VARIABLE_TO_LITERAL:
Integers[p->name1] = p->literal;
break;
case INT_SET_VARIABLE_TO_VARIABLE:
Integers[p->name1] = Integers[p->name2];
break;
case INT_INCREMENT_VARIABLE:
(Integers[p->name1])++;
break;
case INT_SET_VARIABLE_ADD:
Integers[p->name1] = Integers[p->name2] + Integers[p->name3];
break;
case INT_SET_VARIABLE_SUBTRACT:
Integers[p->name1] = Integers[p->name2] - Integers[p->name3];
break;
case INT_SET_VARIABLE_MULTIPLY:
Integers[p->name1] = Integers[p->name2] * Integers[p->name3];
break;
case INT_SET_VARIABLE_DIVIDE:
if(Integers[p->name3] != 0) {
Integers[p->name1] = Integers[p->name2] /
Integers[p->name3];
}
break;
case INT_IF_BIT_SET:
if(!Bits[p->name1]) pc = p->name3;
break;
case INT_IF_BIT_CLEAR:
if(Bits[p->name1]) pc = p->name3;
break;
case INT_IF_VARIABLE_LES_LITERAL:
if(!(Integers[p->name1] < p->literal)) pc = p->name3;
break;
case INT_IF_VARIABLE_EQUALS_VARIABLE:
if(!(Integers[p->name1] == Integers[p->name2])) pc = p->name3;
break;
case INT_IF_VARIABLE_GRT_VARIABLE:
if(!(Integers[p->name1] > Integers[p->name2])) pc = p->name3;
break;
case INT_ELSE:
pc = p->name3;
break;
case INT_END_OF_PROGRAM:
return;
}
}
}
int main(int argc, char **argv)
{
int i;
if(argc != 2) {
fprintf(stderr, "usage: %s xxx.int\n", argv[0]);
return -1;
}
LoadProgram(argv[1]);
memset(Integers, 0, sizeof(Integers));
memset(Bits, 0, sizeof(Bits));
// 1000 cycles times 10 ms gives 10 seconds execution
for(i = 0; i < 1000; i++) {
InterpretOneCycle();
// Example for reaching in and reading a variable: just print it.
printf("a = %d \r", Integers[SpecialAddrForA]);
// Example for reaching in and writing a variable.
Bits[SpecialAddrForXosc] = !Bits[SpecialAddrForXosc];
// XXX, nonportable; replace with whatever timing functions are
// available on your target.
Sleep(10);
}
return 0;
}

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

View File

@ -0,0 +1,22 @@
<?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>

View File

@ -0,0 +1,757 @@
//-----------------------------------------------------------------------------
// 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 __LDMICRO_H
#define __LDMICRO_H
#include <setjmp.h>
typedef signed short SWORD;
typedef signed long SDWORD;
//-----------------------------------------------
// `Configuration options.'
// The library that I use to do registry stuff.
#define FREEZE_SUBKEY "LDMicro"
// Size of the font that we will use to draw the ladder diagrams, in pixels
#define FONT_WIDTH 7
#define FONT_HEIGHT 13
//-----------------------------------------------
// Constants for the GUI. We have drop-down menus, a listview for the I/Os,
// etc.
// Menu IDs
#define MNU_NEW 0x01
#define MNU_OPEN 0x02
#define MNU_SAVE 0x03
#define MNU_SAVE_AS 0x04
#define MNU_EXPORT 0x05
#define MNU_EXIT 0x06
#define MNU_UNDO 0x10
#define MNU_REDO 0x11
#define MNU_PUSH_RUNG_UP 0x12
#define MNU_PUSH_RUNG_DOWN 0x13
#define MNU_INSERT_RUNG_BEFORE 0x14
#define MNU_INSERT_RUNG_AFTER 0x15
#define MNU_DELETE_ELEMENT 0x16
#define MNU_DELETE_RUNG 0x17
#define MNU_INSERT_COMMENT 0x20
#define MNU_INSERT_CONTACTS 0x21
#define MNU_INSERT_COIL 0x22
#define MNU_INSERT_TON 0x23
#define MNU_INSERT_TOF 0x24
#define MNU_INSERT_RTO 0x25
#define MNU_INSERT_RES 0x26
#define MNU_INSERT_OSR 0x27
#define MNU_INSERT_OSF 0x28
#define MNU_INSERT_CTU 0x29
#define MNU_INSERT_CTD 0x2a
#define MNU_INSERT_CTC 0x2b
#define MNU_INSERT_ADD 0x2c
#define MNU_INSERT_SUB 0x2d
#define MNU_INSERT_MUL 0x2e
#define MNU_INSERT_DIV 0x2f
#define MNU_INSERT_MOV 0x30
#define MNU_INSERT_READ_ADC 0x31
#define MNU_INSERT_SET_PWM 0x32
#define MNU_INSERT_UART_SEND 0x33
#define MNU_INSERT_UART_RECV 0x34
#define MNU_INSERT_EQU 0x35
#define MNU_INSERT_NEQ 0x36
#define MNU_INSERT_GRT 0x37
#define MNU_INSERT_GEQ 0x38
#define MNU_INSERT_LES 0x39
#define MNU_INSERT_LEQ 0x3a
#define MNU_INSERT_OPEN 0x3b
#define MNU_INSERT_SHORT 0x3c
#define MNU_INSERT_MASTER_RLY 0x3d
#define MNU_INSERT_SHIFT_REG 0x3e
#define MNU_INSERT_LUT 0x3f
#define MNU_INSERT_FMTD_STR 0x40
#define MNU_INSERT_PERSIST 0x41
#define MNU_MAKE_NORMAL 0x42
#define MNU_NEGATE 0x43
#define MNU_MAKE_SET_ONLY 0x44
#define MNU_MAKE_RESET_ONLY 0x45
#define MNU_INSERT_PWL 0x46
#define MNU_MCU_SETTINGS 0x50
#define MNU_PROCESSOR_0 0xa0
#define MNU_SIMULATION_MODE 0x60
#define MNU_START_SIMULATION 0x61
#define MNU_STOP_SIMULATION 0x62
#define MNU_SINGLE_CYCLE 0x63
#define MNU_COMPILE 0x70
#define MNU_COMPILE_AS 0x71
#define MNU_MANUAL 0x80
#define MNU_ABOUT 0x81
// Columns within the I/O etc. listview.
#define LV_IO_NAME 0x00
#define LV_IO_TYPE 0x01
#define LV_IO_STATE 0x02
#define LV_IO_PIN 0x03
#define LV_IO_PORT 0x04
// Timer IDs associated with the main window.
#define TIMER_BLINK_CURSOR 1
#define TIMER_SIMULATE 2
//-----------------------------------------------
// Data structures for the actual ladder logic. A rung on the ladder
// is a series subcircuit. A series subcircuit contains elements or
// parallel subcircuits. A parallel subcircuit contains elements or series
// subcircuits. An element is a set of contacts (possibly negated) or a coil.
#define MAX_ELEMENTS_IN_SUBCKT 16
#define ELEM_PLACEHOLDER 0x01
#define ELEM_SERIES_SUBCKT 0x02
#define ELEM_PARALLEL_SUBCKT 0x03
#define ELEM_PADDING 0x04
#define ELEM_COMMENT 0x05
#define ELEM_CONTACTS 0x10
#define ELEM_COIL 0x11
#define ELEM_TON 0x12
#define ELEM_TOF 0x13
#define ELEM_RTO 0x14
#define ELEM_RES 0x15
#define ELEM_ONE_SHOT_RISING 0x16
#define ELEM_ONE_SHOT_FALLING 0x17
#define ELEM_MOVE 0x18
#define ELEM_ADD 0x19
#define ELEM_SUB 0x1a
#define ELEM_MUL 0x1b
#define ELEM_DIV 0x1c
#define ELEM_EQU 0x1d
#define ELEM_NEQ 0x1e
#define ELEM_GRT 0x1f
#define ELEM_GEQ 0x20
#define ELEM_LES 0x21
#define ELEM_LEQ 0x22
#define ELEM_CTU 0x23
#define ELEM_CTD 0x24
#define ELEM_CTC 0x25
#define ELEM_SHORT 0x26
#define ELEM_OPEN 0x27
#define ELEM_READ_ADC 0x28
#define ELEM_SET_PWM 0x29
#define ELEM_UART_RECV 0x2a
#define ELEM_UART_SEND 0x2b
#define ELEM_MASTER_RELAY 0x2c
#define ELEM_SHIFT_REGISTER 0x2d
#define ELEM_LOOK_UP_TABLE 0x2e
#define ELEM_FORMATTED_STRING 0x2f
#define ELEM_PERSIST 0x30
#define ELEM_PIECEWISE_LINEAR 0x31
#define CASE_LEAF \
case ELEM_PLACEHOLDER: \
case ELEM_COMMENT: \
case ELEM_COIL: \
case ELEM_CONTACTS: \
case ELEM_TON: \
case ELEM_TOF: \
case ELEM_RTO: \
case ELEM_CTD: \
case ELEM_CTU: \
case ELEM_CTC: \
case ELEM_RES: \
case ELEM_ONE_SHOT_RISING: \
case ELEM_ONE_SHOT_FALLING: \
case ELEM_EQU: \
case ELEM_NEQ: \
case ELEM_GRT: \
case ELEM_GEQ: \
case ELEM_LES: \
case ELEM_LEQ: \
case ELEM_ADD: \
case ELEM_SUB: \
case ELEM_MUL: \
case ELEM_DIV: \
case ELEM_MOVE: \
case ELEM_SHORT: \
case ELEM_OPEN: \
case ELEM_READ_ADC: \
case ELEM_SET_PWM: \
case ELEM_UART_SEND: \
case ELEM_UART_RECV: \
case ELEM_MASTER_RELAY: \
case ELEM_SHIFT_REGISTER: \
case ELEM_LOOK_UP_TABLE: \
case ELEM_PIECEWISE_LINEAR: \
case ELEM_FORMATTED_STRING: \
case ELEM_PERSIST:
#define MAX_NAME_LEN 128
#define MAX_COMMENT_LEN 384
#define MAX_LOOK_UP_TABLE_LEN 60
typedef struct ElemSubckParallelTag ElemSubcktParallel;
typedef struct ElemCommentTag {
char str[MAX_COMMENT_LEN];
} ElemComment;
typedef struct ElemContactsTag {
char name[MAX_NAME_LEN];
BOOL negated;
} ElemContacts;
typedef struct ElemCoilTag {
char name[MAX_NAME_LEN];
BOOL negated;
BOOL setOnly;
BOOL resetOnly;
} ElemCoil;
typedef struct ElemTimeTag {
char name[MAX_NAME_LEN];
int delay;
} ElemTimer;
typedef struct ElemResetTag {
char name[MAX_NAME_LEN];
} ElemReset;
typedef struct ElemMoveTag {
char src[MAX_NAME_LEN];
char dest[MAX_NAME_LEN];
} ElemMove;
typedef struct ElemMathTag {
char op1[MAX_NAME_LEN];
char op2[MAX_NAME_LEN];
char dest[MAX_NAME_LEN];
} ElemMath;
typedef struct ElemCmpTag {
char op1[MAX_NAME_LEN];
char op2[MAX_NAME_LEN];
} ElemCmp;
typedef struct ElemCounterTag {
char name[MAX_NAME_LEN];
int max;
} ElemCounter;
typedef struct ElemReadAdcTag {
char name[MAX_NAME_LEN];
} ElemReadAdc;
typedef struct ElemSetPwmTag {
char name[MAX_NAME_LEN];
int targetFreq;
} ElemSetPwm;
typedef struct ElemUartTag {
char name[MAX_NAME_LEN];
} ElemUart;
typedef struct ElemShiftRegisterTag {
char name[MAX_NAME_LEN];
int stages;
} ElemShiftRegister;
typedef struct ElemLookUpTableTag {
char dest[MAX_NAME_LEN];
char index[MAX_NAME_LEN];
int count;
BOOL editAsString;
SWORD vals[MAX_LOOK_UP_TABLE_LEN];
} ElemLookUpTable;
typedef struct ElemPiecewiseLinearTag {
char dest[MAX_NAME_LEN];
char index[MAX_NAME_LEN];
int count;
SWORD vals[MAX_LOOK_UP_TABLE_LEN];
} ElemPiecewiseLinear;
typedef struct ElemFormattedStringTag {
char var[MAX_NAME_LEN];
char string[MAX_LOOK_UP_TABLE_LEN];
} ElemFormattedString;
typedef struct ElemPerisistTag {
char var[MAX_NAME_LEN];
} ElemPersist;
#define SELECTED_NONE 0
#define SELECTED_ABOVE 1
#define SELECTED_BELOW 2
#define SELECTED_RIGHT 3
#define SELECTED_LEFT 4
typedef struct ElemLeafTag {
int selectedState;
BOOL poweredAfter;
union {
ElemComment comment;
ElemContacts contacts;
ElemCoil coil;
ElemTimer timer;
ElemReset reset;
ElemMove move;
ElemMath math;
ElemCmp cmp;
ElemCounter counter;
ElemReadAdc readAdc;
ElemSetPwmTag setPwm;
ElemUart uart;
ElemShiftRegister shiftRegister;
ElemFormattedString fmtdStr;
ElemLookUpTable lookUpTable;
ElemPiecewiseLinear piecewiseLinear;
ElemPersist persist;
} d;
} ElemLeaf;
typedef struct ElemSubcktSeriesTag {
struct {
int which;
union {
void *any;
ElemSubcktParallel *parallel;
ElemLeaf *leaf;
} d;
} contents[MAX_ELEMENTS_IN_SUBCKT];
int count;
} ElemSubcktSeries;
typedef struct ElemSubckParallelTag {
struct {
int which;
union {
void *any;
ElemSubcktSeries *series;
ElemLeaf *leaf;
} d;
} contents[MAX_ELEMENTS_IN_SUBCKT];
int count;
} ElemSubcktParallel;
typedef struct McuIoInfoTag McuIoInfo;
typedef struct PlcProgramSingleIoTag {
char name[MAX_NAME_LEN];
#define IO_TYPE_PENDING 0
#define IO_TYPE_DIG_INPUT 1
#define IO_TYPE_DIG_OUTPUT 2
#define IO_TYPE_READ_ADC 3
#define IO_TYPE_UART_TX 4
#define IO_TYPE_UART_RX 5
#define IO_TYPE_PWM_OUTPUT 6
#define IO_TYPE_INTERNAL_RELAY 7
#define IO_TYPE_TON 8
#define IO_TYPE_TOF 9
#define IO_TYPE_RTO 10
#define IO_TYPE_COUNTER 11
#define IO_TYPE_GENERAL 12
int type;
#define NO_PIN_ASSIGNED 0
int pin;
} PlcProgramSingleIo;
#define MAX_IO 512
typedef struct PlcProgramTag {
struct {
PlcProgramSingleIo assignment[MAX_IO];
int count;
} io;
McuIoInfo *mcu;
int cycleTime;
int mcuClock;
int baudRate;
#define MAX_RUNGS 99
ElemSubcktSeries *rungs[MAX_RUNGS];
BOOL rungPowered[MAX_RUNGS];
int numRungs;
} PlcProgram;
//-----------------------------------------------
// For actually drawing the ladder logic on screen; constants that determine
// how the boxes are laid out in the window, need to know that lots of
// places for figuring out if a mouse click is in a box etc.
// dimensions, in characters, of the area reserved for 1 leaf element
#define POS_WIDTH 17
#define POS_HEIGHT 3
// offset from the top left of the window at which we start drawing, in pixels
#define X_PADDING 35
#define Y_PADDING 14
typedef struct PlcCursorTag {
int left;
int top;
int width;
int height;
} PlcCursor;
//-----------------------------------------------
// The syntax highlighting style colours; a structure for the palette.
typedef struct SyntaxHighlightingColoursTag {
COLORREF bg; // background
COLORREF def; // default foreground
COLORREF selected; // selected element
COLORREF op; // `op code' (like OSR, OSF, ADD, ...)
COLORREF punct; // punctuation, like square or curly braces
COLORREF lit; // a literal number
COLORREF name; // the name of an item
COLORREF rungNum; // rung numbers
COLORREF comment; // user-written comment text
COLORREF bus; // the `bus' at the right and left of screen
COLORREF simBg; // background, simulation mode
COLORREF simRungNum; // rung number, simulation mode
COLORREF simOff; // de-energized element, simulation mode
COLORREF simOn; // energzied element, simulation mode
COLORREF simBusLeft; // the `bus,' can be different colours for
COLORREF simBusRight; // right and left of the screen
} SyntaxHighlightingColours;
extern SyntaxHighlightingColours HighlightColours;
//-----------------------------------------------
// Processor definitions. These tables tell us where to find the I/Os on
// a processor, what bit in what register goes with what pin, etc. There
// is one master SupportedMcus table, which contains entries for each
// supported microcontroller.
typedef struct McuIoPinInfoTag {
char port;
int bit;
int pin;
} McuIoPinInfo;
typedef struct McuAdcPinInfoTag {
int pin;
BYTE muxRegValue;
} McuAdcPinInfo;
#define ISA_AVR 0x00
#define ISA_PIC16 0x01
#define ISA_ANSIC 0x02
#define ISA_INTERPRETED 0x03
#define MAX_IO_PORTS 10
#define MAX_RAM_SECTIONS 5
typedef struct McuIoInfoTag {
char *mcuName;
char portPrefix;
DWORD inputRegs[MAX_IO_PORTS]; // a is 0, j is 9
DWORD outputRegs[MAX_IO_PORTS];
DWORD dirRegs[MAX_IO_PORTS];
DWORD flashWords;
struct {
DWORD start;
int len;
} ram[MAX_RAM_SECTIONS];
McuIoPinInfo *pinInfo;
int pinCount;
McuAdcPinInfo *adcInfo;
int adcCount;
int adcMax;
struct {
int rxPin;
int txPin;
} uartNeeds;
int pwmNeedsPin;
int whichIsa;
BOOL avrUseIjmp;
DWORD configurationWord;
} McuIoInfo;
#define NUM_SUPPORTED_MCUS 15
//-----------------------------------------------
// 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 HWND MainWindow;
extern HDC Hdc;
extern PlcProgram Prog;
extern char CurrentSaveFile[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
void CheckHeap(char *file, int line);
#define ok() CheckHeap(__FILE__, __LINE__)
// maincontrols.cpp
void MakeMainWindowControls(void);
HMENU MakeMainWindowMenus(void);
void VscrollProc(WPARAM wParam);
void HscrollProc(WPARAM wParam);
void GenerateIoListDontLoseSelection(void);
void RefreshControlsToSettings(void);
void MainWindowResized(void);
void ToggleSimulationMode(void);
void StopSimulation(void);
void StartSimulation(void);
void UpdateMainWindowTitleBar(void);
extern int ScrollWidth;
extern int ScrollHeight;
extern BOOL NeedHoriz;
extern HWND IoList;
extern int IoListTop;
extern int IoListHeight;
// draw.cpp
int ProgCountWidestRow(void);
int CountHeightOfElement(int which, void *elem);
BOOL DrawElement(int which, void *elem, int *cx, int *cy, BOOL poweredBefore);
void DrawEndRung(int cx, int cy);
extern int ColsAvailable;
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 HFONT FixedWidthFont;
extern HFONT FixedWidthFontBold;
extern int SelectedGxAfterNextPaint;
extern int SelectedGyAfterNextPaint;
extern BOOL ScrollSelectedIntoViewAfterNextPaint;
extern int ScrollXOffset;
extern int ScrollYOffset;
extern int ScrollXOffsetMax;
extern int ScrollYOffsetMax;
// schematic.cpp
void SelectElement(int gx, int gy, int state);
void MoveCursorKeyboard(int keyCode);
void MoveCursorMouseClick(int x, int y);
BOOL MoveCursorTopLeft(void);
void EditElementMouseDoubleclick(int x, int y);
void EditSelectedElement(void);
void MakeResetOnlySelected(void);
void MakeSetOnlySelected(void);
void MakeNormalSelected(void);
void NegateSelected(void);
void ForgetFromGrid(void *p);
void ForgetEverything(void);
void WhatCanWeDoFromCursorAndTopology(void);
BOOL FindSelected(int *gx, int *gy);
void MoveCursorNear(int gx, int gy);
#define DISPLAY_MATRIX_X_SIZE 16
#define DISPLAY_MATRIX_Y_SIZE 512
extern ElemLeaf *DisplayMatrix[DISPLAY_MATRIX_X_SIZE][DISPLAY_MATRIX_Y_SIZE];
extern int DisplayMatrixWhich[DISPLAY_MATRIX_X_SIZE][DISPLAY_MATRIX_Y_SIZE];
extern ElemLeaf DisplayMatrixFiller;
#define PADDING_IN_DISPLAY_MATRIX (&DisplayMatrixFiller)
#define VALID_LEAF(x) ((x) != NULL && (x) != PADDING_IN_DISPLAY_MATRIX)
extern ElemLeaf *Selected;
extern int SelectedWhich;
extern PlcCursor Cursor;
extern BOOL CanInsertEnd;
extern BOOL CanInsertOther;
extern BOOL CanInsertComment;
// circuit.cpp
void AddTimer(int which);
void AddCoil(void);
void AddContact(void);
void AddEmpty(int which);
void AddMove(void);
void AddMath(int which);
void AddCmp(int which);
void AddReset(void);
void AddCounter(int which);
void AddReadAdc(void);
void AddSetPwm(void);
void AddUart(int which);
void AddPersist(void);
void AddComment(char *text);
void AddShiftRegister(void);
void AddMasterRelay(void);
void AddLookUpTable(void);
void AddPiecewiseLinear(void);
void AddFormattedString(void);
void DeleteSelectedFromProgram(void);
void DeleteSelectedRung(void);
void InsertRung(BOOL afterCursor);
int RungContainingSelected(void);
BOOL ItemIsLastInCircuit(ElemLeaf *item);
BOOL UartFunctionUsed(void);
BOOL PwmFunctionUsed(void);
void PushRungUp(void);
void PushRungDown(void);
void NewProgram(void);
ElemLeaf *AllocLeaf(void);
ElemSubcktSeries *AllocSubcktSeries(void);
ElemSubcktParallel *AllocSubcktParallel(void);
void FreeCircuit(int which, void *any);
void FreeEntireProgram(void);
void UndoUndo(void);
void UndoRedo(void);
void UndoRemember(void);
void UndoFlush(void);
BOOL CanUndo(void);
// loadsave.cpp
BOOL LoadProjectFromFile(char *filename);
BOOL SaveProjectToFile(char *filename);
// iolist.cpp
int GenerateIoList(int prevSel);
void SaveIoListToFile(FILE *f);
BOOL LoadIoListFromFile(FILE *f);
void ShowIoDialog(int item);
void IoListProc(NMHDR *h);
void ShowAnalogSliderPopup(char *name);
// commentdialog.cpp
void ShowCommentDialog(char *comment);
// contactsdialog.cpp
void ShowContactsDialog(BOOL *negated, char *name);
// coildialog.cpp
void ShowCoilDialog(BOOL *negated, BOOL *setOnly, BOOL *resetOnly, char *name);
// simpledialog.cpp
void ShowTimerDialog(int which, int *delay, char *name);
void ShowCounterDialog(int which, int *count, char *name);
void ShowMoveDialog(char *dest, char *src);
void ShowReadAdcDialog(char *name);
void ShowSetPwmDialog(char *name, int *targetFreq);
void ShowPersistDialog(char *var);
void ShowUartDialog(int which, char *name);
void ShowCmpDialog(int which, char *op1, char *op2);
void ShowMathDialog(int which, char *dest, char *op1, char *op2);
void ShowShiftRegisterDialog(char *name, int *stages);
void ShowFormattedStringDialog(char *var, char *string);
void ShowLookUpTableDialog(ElemLeaf *l);
void ShowPiecewiseLinearDialog(ElemLeaf *l);
void ShowResetDialog(char *name);
// confdialog.cpp
void ShowConfDialog(void);
// helpdialog.cpp
void ShowHelpDialog(BOOL about);
// miscutil.cpp
#define oops() { \
dbp("bad at %d %s\n", __LINE__, __FILE__); \
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);
void CheckFree(void *p);
extern HANDLE MainHeap;
void StartIhex(FILE *f);
void WriteIhex(FILE *f, BYTE b);
void FinishIhex(FILE *f);
char *IoTypeToString(int ioType);
void PinNumberForIo(char *dest, PlcProgramSingleIo *io);
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);
void MakeDialogBoxClass(void);
void NiceFont(HWND h);
void FixedFont(HWND h);
void CompileSuccessfulMessage(char *str);
extern BOOL RunningInBatchMode;
extern HFONT MyNiceFont;
extern HFONT MyFixedFont;
extern HWND OkButton;
extern HWND CancelButton;
extern BOOL DialogDone;
extern BOOL DialogCancel;
// lang.cpp
char *_(char *in);
// simulate.cpp
void SimulateOneCycle(BOOL forceRefresh);
void CALLBACK PlcCycleTimer(HWND hwnd, UINT msg, UINT_PTR id, DWORD time);
void StartSimulationTimer(void);
void ClearSimulationData(void);
void DescribeForIoList(char *name, char *out);
void SimulationToggleContact(char *name);
void SetAdcShadow(char *name, SWORD val);
SWORD GetAdcShadow(char *name);
void DestroyUartSimulationWindow(void);
void ShowUartSimulationWindow(void);
extern BOOL InSimulationMode;
extern BOOL SimulateRedrawAfterNextCycle;
// compilecommon.cpp
void AllocStart(void);
DWORD AllocOctetRam(void);
void AllocBitRam(DWORD *addr, int *bit);
void MemForVariable(char *name, DWORD *addrl, DWORD *addrh);
BYTE MuxForAdcVariable(char *name);
void MemForSingleBit(char *name, BOOL forRead, DWORD *addr, int *bit);
void MemCheckForErrorsPostCompile(void);
void BuildDirectionRegisters(BYTE *isInput, BYTE *isOutput);
void ComplainAboutBaudRateError(int divisor, double actual, double err);
void ComplainAboutBaudRateOverflow(void);
#define CompileError() longjmp(CompileErrorBuf, 1)
extern jmp_buf CompileErrorBuf;
// intcode.cpp
void IntDumpListing(char *outFile);
BOOL GenerateIntermediateCode(void);
// pic16.cpp
void CompilePic16(char *outFile);
// avr.cpp
void CompileAvr(char *outFile);
// ansic.cpp
void CompileAnsiC(char *outFile);
// interpreted.c
void CompileInterpreted(char *outFile);
#endif

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.9 KiB

View File

@ -0,0 +1,6 @@
// 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)
1 24 "ldmicro.exe.manifest"
4000 ICON "ldmicro.ico"

View File

@ -0,0 +1,649 @@
//-----------------------------------------------------------------------------
// 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/>.
//------
//
// Load/save the circuit from/to a file in a nice ASCII format.
// Jonathan Westhues, Nov 2004
//-----------------------------------------------------------------------------
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include "ldmicro.h"
static ElemSubcktSeries *LoadSeriesFromFile(FILE *f);
//-----------------------------------------------------------------------------
// Check a line of text from a saved project file to determine whether it
// contains a leaf element (coil, contacts, etc.). If so, create an element
// for and save that in *any and *which, and return TRUE, else return FALSE.
//-----------------------------------------------------------------------------
static BOOL LoadLeafFromFile(char *line, void **any, int *which)
{
ElemLeaf *l = AllocLeaf();
int x;
if(memcmp(line, "COMMENT", 7)==0) {
char *s = line + 8;
int i = 0;
while(*s && *s != '\n') {
if(*s == '\\') {
if(s[1] == 'n') {
l->d.comment.str[i++] = '\n';
s++;
} else if(s[1] == 'r') {
l->d.comment.str[i++] = '\r';
s++;
} else if(s[1] == '\\') {
l->d.comment.str[i++] = '\\';
s++;
} else {
// that is odd
}
} else {
l->d.comment.str[i++] = *s;
}
s++;
}
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)
{
*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)
{
*which = ELEM_COIL;
} else if(memcmp(line, "PLACEHOLDER", 11)==0) {
*which = ELEM_PLACEHOLDER;
} else if(memcmp(line, "SHORT", 5)==0) {
*which = ELEM_SHORT;
} else if(memcmp(line, "OPEN", 4)==0) {
*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)
{
*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))
{
*which = ELEM_TON;
} 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))
{
*which = ELEM_RTO;
} 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))
{
*which = ELEM_CTU;
} 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)
{
*which = ELEM_ADD;
} 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)
{
*which = ELEM_MUL;
} 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) {
*which = ELEM_EQU;
} else if(sscanf(line, "NEQ %s %s", l->d.cmp.op1, l->d.cmp.op2)==2) {
*which = ELEM_NEQ;
} else if(sscanf(line, "GRT %s %s", l->d.cmp.op1, l->d.cmp.op2)==2) {
*which = ELEM_GRT;
} else if(sscanf(line, "GEQ %s %s", l->d.cmp.op1, l->d.cmp.op2)==2) {
*which = ELEM_GEQ;
} else if(sscanf(line, "LEQ %s %s", l->d.cmp.op1, l->d.cmp.op2)==2) {
*which = ELEM_LEQ;
} else if(sscanf(line, "LES %s %s", l->d.cmp.op1, l->d.cmp.op2)==2) {
*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)
{
*which = ELEM_SET_PWM;
} else if(sscanf(line, "UART_RECV %s", l->d.uart.name)==1) {
*which = ELEM_UART_RECV;
} else if(sscanf(line, "UART_SEND %s", l->d.uart.name)==1) {
*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)
{
if(strcmp(l->d.fmtdStr.var, "(none)")==0) {
strcpy(l->d.fmtdStr.var, "");
}
char *p = line;
int i;
for(i = 0; i < 3; i++) {
while(!isspace(*p)) p++;
while( isspace(*p)) p++;
}
for(i = 0; i < x; i++) {
l->d.fmtdStr.string[i] = atoi(p);
if(l->d.fmtdStr.string[i] < 32) {
l->d.fmtdStr.string[i] = 'X';
}
while(!isspace(*p) && *p) p++;
while( isspace(*p) && *p) p++;
}
l->d.fmtdStr.string[i] = '\0';
*which = ELEM_FORMATTED_STRING;
} else if(sscanf(line, "LOOK_UP_TABLE %s %s %d %d", l->d.lookUpTable.dest,
l->d.lookUpTable.index, &(l->d.lookUpTable.count),
&(l->d.lookUpTable.editAsString))==4)
{
char *p = line;
int i;
// First skip over the parts that we already sscanf'd.
for(i = 0; i < 5; i++) {
while((!isspace(*p)) && *p)
p++;
while(isspace(*p) && *p)
p++;
}
// Then copy over the look-up table entries.
for(i = 0; i < l->d.lookUpTable.count; i++) {
l->d.lookUpTable.vals[i] = atoi(p);
while((!isspace(*p)) && *p)
p++;
while(isspace(*p) && *p)
p++;
}
*which = ELEM_LOOK_UP_TABLE;
} else if(sscanf(line, "PIECEWISE_LINEAR %s %s %d",
l->d.piecewiseLinear.dest, l->d.piecewiseLinear.index,
&(l->d.piecewiseLinear.count))==3)
{
char *p = line;
int i;
// First skip over the parts that we already sscanf'd.
for(i = 0; i < 4; i++) {
while((!isspace(*p)) && *p)
p++;
while(isspace(*p) && *p)
p++;
}
// Then copy over the piecewise linear points.
for(i = 0; i < l->d.piecewiseLinear.count*2; i++) {
l->d.piecewiseLinear.vals[i] = atoi(p);
while((!isspace(*p)) && *p)
p++;
while(isspace(*p) && *p)
p++;
}
*which = ELEM_PIECEWISE_LINEAR;
} else {
// that's odd; nothing matched
CheckFree(l);
return FALSE;
}
*any = l;
return TRUE;
}
//-----------------------------------------------------------------------------
// Load a parallel subcircuit from a file. We look for leaf nodes using
// LoadLeafFromFile, which we can put directly into the parallel circuit
// that we're building up, or series subcircuits that we can pass to
// LoadSeriesFromFile. Returns the parallel subcircuit built up, or NULL if
// something goes wrong.
//-----------------------------------------------------------------------------
static ElemSubcktParallel *LoadParallelFromFile(FILE *f)
{
char line[512];
void *any;
int which;
ElemSubcktParallel *ret = AllocSubcktParallel();
int cnt = 0;
for(;;) {
if(!fgets(line, sizeof(line), f)) return NULL;
char *s = line;
while(isspace(*s)) s++;
if(strcmp(s, "SERIES\n")==0) {
which = ELEM_SERIES_SUBCKT;
any = LoadSeriesFromFile(f);
if(!any) return NULL;
} else if(LoadLeafFromFile(s, &any, &which)) {
// got it
} else if(strcmp(s, "END\n")==0) {
ret->count = cnt;
return ret;
} else {
return NULL;
}
ret->contents[cnt].which = which;
ret->contents[cnt].d.any = any;
cnt++;
if(cnt >= MAX_ELEMENTS_IN_SUBCKT) return NULL;
}
}
//-----------------------------------------------------------------------------
// Same as LoadParallelFromFile, but for a series subcircuit. Thus builds
// a series circuit out of parallel circuits and leaf elements.
//-----------------------------------------------------------------------------
static ElemSubcktSeries *LoadSeriesFromFile(FILE *f)
{
char line[512];
void *any;
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)) {
// got it
} else if(strcmp(s, "END\n")==0) {
ret->count = cnt;
return ret;
} else {
return NULL;
}
ret->contents[cnt].which = which;
ret->contents[cnt].d.any = any;
cnt++;
if(cnt >= MAX_ELEMENTS_IN_SUBCKT) return NULL;
}
}
//-----------------------------------------------------------------------------
// Load a project from a saved project description files. This describes the
// program, the target processor, plus certain configuration settings (cycle
// time, processor clock, etc.). Return TRUE for success, FALSE if anything
// went wrong.
//-----------------------------------------------------------------------------
BOOL LoadProjectFromFile(char *filename)
{
FreeEntireProgram();
strcpy(CurrentCompileFile, "");
FILE *f = fopen(filename, "r");
if(!f) return FALSE;
char line[512];
int crystal, cycle, baud;
while(fgets(line, sizeof(line), f)) {
if(strcmp(line, "IO LIST\n")==0) {
if(!LoadIoListFromFile(f)) {
fclose(f);
return FALSE;
}
} else if(sscanf(line, "CRYSTAL=%d", &crystal)) {
Prog.mcuClock = crystal;
} else if(sscanf(line, "CYCLE=%d", &cycle)) {
Prog.cycleTime = cycle;
} else if(sscanf(line, "BAUD=%d", &baud)) {
Prog.baudRate = baud;
} else if(memcmp(line, "COMPILED=", 9)==0) {
line[strlen(line)-1] = '\0';
strcpy(CurrentCompileFile, line+9);
} else if(memcmp(line, "MICRO=", 6)==0) {
line[strlen(line)-1] = '\0';
int i;
for(i = 0; i < NUM_SUPPORTED_MCUS; i++) {
if(strcmp(SupportedMcus[i].mcuName, line+6)==0) {
Prog.mcu = &SupportedMcus[i];
break;
}
}
if(i == NUM_SUPPORTED_MCUS) {
Error(_("Microcontroller '%s' not supported.\r\n\r\n"
"Defaulting to no selected MCU."), line+6);
}
} else if(strcmp(line, "PROGRAM\n")==0) {
break;
}
}
if(strcmp(line, "PROGRAM\n") != 0) goto failed;
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;
rung++;
}
Prog.numRungs = rung;
fclose(f);
return TRUE;
failed:
fclose(f);
NewProgram();
Error(_("File format error; perhaps this program is for a newer version "
"of LDmicro?"));
return FALSE;
}
//-----------------------------------------------------------------------------
// Helper routine for outputting hierarchical representation of the ladder
// logic: indent on file f, by depth*4 spaces.
//-----------------------------------------------------------------------------
static void Indent(FILE *f, int depth)
{
int i;
for(i = 0; i < depth; i++) {
fprintf(f, " ");
}
}
//-----------------------------------------------------------------------------
// Save an element to a file. If it is a leaf, then output a single line
// describing it and return. If it is a subcircuit, call ourselves
// recursively (with depth+1, so that the indentation is right) to handle
// the members of the subcircuit. Special case for depth=0: we do not
// output the SERIES/END delimiters. This is because the root is delimited
// by RUNG/END markers output elsewhere.
//-----------------------------------------------------------------------------
static void SaveElemToFile(FILE *f, int which, void *any, int depth)
{
ElemLeaf *l = (ElemLeaf *)any;
char *s;
Indent(f, depth);
switch(which) {
case ELEM_PLACEHOLDER:
fprintf(f, "PLACEHOLDER\n");
break;
case ELEM_COMMENT: {
fprintf(f, "COMMENT ");
char *s = l->d.comment.str;
for(; *s; s++) {
if(*s == '\\') {
fprintf(f, "\\\\");
} else if(*s == '\n') {
fprintf(f, "\\n");
} else if(*s == '\r') {
fprintf(f, "\\r");
} else {
fprintf(f, "%c", *s);
}
}
fprintf(f, "\n");
break;
}
case ELEM_OPEN:
fprintf(f, "OPEN\n");
break;
case ELEM_SHORT:
fprintf(f, "SHORT\n");
break;
case ELEM_MASTER_RELAY:
fprintf(f, "MASTER_RELAY\n");
break;
case ELEM_SHIFT_REGISTER:
fprintf(f, "SHIFT_REGISTER %s %d\n", l->d.shiftRegister.name,
l->d.shiftRegister.stages);
break;
case ELEM_CONTACTS:
fprintf(f, "CONTACTS %s %d\n", l->d.contacts.name,
l->d.contacts.negated);
break;
case ELEM_COIL:
fprintf(f, "COIL %s %d %d %d\n", l->d.coil.name, l->d.coil.negated,
l->d.coil.setOnly, l->d.coil.resetOnly);
break;
case ELEM_TON:
s = "TON"; goto timer;
case ELEM_TOF:
s = "TOF"; goto timer;
case ELEM_RTO:
s = "RTO"; goto timer;
timer:
fprintf(f, "%s %s %d\n", s, l->d.timer.name, l->d.timer.delay);
break;
case ELEM_CTU:
s = "CTU"; goto counter;
case ELEM_CTD:
s = "CTD"; goto counter;
case ELEM_CTC:
s = "CTC"; goto counter;
counter:
fprintf(f, "%s %s %d\n", s, l->d.counter.name, l->d.counter.max);
break;
case ELEM_RES:
fprintf(f, "RES %s\n", l->d.reset.name);
break;
case ELEM_MOVE:
fprintf(f, "MOVE %s %s\n", l->d.move.dest, l->d.move.src);
break;
case ELEM_ADD: s = "ADD"; goto math;
case ELEM_SUB: s = "SUB"; goto math;
case ELEM_MUL: s = "MUL"; goto math;
case ELEM_DIV: s = "DIV"; goto math;
math:
fprintf(f, "%s %s %s %s\n", s, l->d.math.dest, l->d.math.op1,
l->d.math.op2);
break;
case ELEM_EQU: s = "EQU"; goto cmp;
case ELEM_NEQ: s = "NEQ"; goto cmp;
case ELEM_GRT: s = "GRT"; goto cmp;
case ELEM_GEQ: s = "GEQ"; goto cmp;
case ELEM_LES: s = "LES"; goto cmp;
case ELEM_LEQ: s = "LEQ"; goto cmp;
cmp:
fprintf(f, "%s %s %s\n", s, l->d.cmp.op1, l->d.cmp.op2);
break;
case ELEM_ONE_SHOT_RISING:
fprintf(f, "OSR\n");
break;
case ELEM_ONE_SHOT_FALLING:
fprintf(f, "OSF\n");
break;
case ELEM_READ_ADC:
fprintf(f, "READ_ADC %s\n", l->d.readAdc.name);
break;
case ELEM_SET_PWM:
fprintf(f, "SET_PWM %s %d\n", l->d.setPwm.name,
l->d.setPwm.targetFreq);
break;
case ELEM_UART_RECV:
fprintf(f, "UART_RECV %s\n", l->d.uart.name);
break;
case ELEM_UART_SEND:
fprintf(f, "UART_SEND %s\n", l->d.uart.name);
break;
case ELEM_PERSIST:
fprintf(f, "PERSIST %s\n", l->d.persist.var);
break;
case ELEM_FORMATTED_STRING: {
int i;
fprintf(f, "FORMATTED_STRING ");
if(*(l->d.fmtdStr.var)) {
fprintf(f, "%s", l->d.fmtdStr.var);
} else {
fprintf(f, "(none)");
}
fprintf(f, " %d", strlen(l->d.fmtdStr.string));
for(i = 0; i < (int)strlen(l->d.fmtdStr.string); i++) {
fprintf(f, " %d", l->d.fmtdStr.string[i]);
}
fprintf(f, "\n");
break;
}
case ELEM_LOOK_UP_TABLE: {
int i;
fprintf(f, "LOOK_UP_TABLE %s %s %d %d", l->d.lookUpTable.dest,
l->d.lookUpTable.index, l->d.lookUpTable.count,
l->d.lookUpTable.editAsString);
for(i = 0; i < l->d.lookUpTable.count; i++) {
fprintf(f, " %d", l->d.lookUpTable.vals[i]);
}
fprintf(f, "\n");
break;
}
case ELEM_PIECEWISE_LINEAR: {
int i;
fprintf(f, "PIECEWISE_LINEAR %s %s %d", l->d.piecewiseLinear.dest,
l->d.piecewiseLinear.index, l->d.piecewiseLinear.count);
for(i = 0; i < l->d.piecewiseLinear.count*2; i++) {
fprintf(f, " %d", l->d.piecewiseLinear.vals[i]);
}
fprintf(f, "\n");
break;
}
case ELEM_SERIES_SUBCKT: {
ElemSubcktSeries *s = (ElemSubcktSeries *)any;
int i;
if(depth == 0) {
fprintf(f, "RUNG\n");
} else {
fprintf(f, "SERIES\n");
}
for(i = 0; i < s->count; i++) {
SaveElemToFile(f, s->contents[i].which, s->contents[i].d.any,
depth+1);
}
Indent(f, depth);
fprintf(f, "END\n");
break;
}
case ELEM_PARALLEL_SUBCKT: {
ElemSubcktParallel *s = (ElemSubcktParallel *)any;
int i;
fprintf(f, "PARALLEL\n");
for(i = 0; i < s->count; i++) {
SaveElemToFile(f, s->contents[i].which, s->contents[i].d.any,
depth+1);
}
Indent(f, depth);
fprintf(f, "END\n");
break;
}
default:
oops();
break;
}
}
//-----------------------------------------------------------------------------
// Save the program in memory to the given file. Returns TRUE for success,
// FALSE otherwise.
//-----------------------------------------------------------------------------
BOOL SaveProjectToFile(char *filename)
{
FILE *f = fopen(filename, "w");
if(!f) return FALSE;
fprintf(f, "LDmicro0.1\n");
if(Prog.mcu) {
fprintf(f, "MICRO=%s\n", Prog.mcu->mcuName);
}
fprintf(f, "CYCLE=%d\n", Prog.cycleTime);
fprintf(f, "CRYSTAL=%d\n", Prog.mcuClock);
fprintf(f, "BAUD=%d\n", Prog.baudRate);
if(strlen(CurrentCompileFile) > 0) {
fprintf(f, "COMPILED=%s\n", CurrentCompileFile);
}
fprintf(f, "\n");
// list extracted from schematic, but the pin assignments are not
fprintf(f, "IO LIST\n", Prog.mcuClock);
SaveIoListToFile(f);
fprintf(f, "END\n", Prog.mcuClock);
fprintf(f, "\n", Prog.mcuClock);
fprintf(f, "PROGRAM\n", Prog.mcuClock);
int i;
for(i = 0; i < Prog.numRungs; i++) {
SaveElemToFile(f, ELEM_SERIES_SUBCKT, Prog.rungs[i], 0);
}
fclose(f);
return TRUE;
}

View File

@ -0,0 +1,565 @@
//-----------------------------------------------------------------------------
// 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/>.
//------
//
// Dialog for entering the elements of a look-up table. I allow two formats:
// as a simple list of integer values, or like a string. The lookup table
// can either be a straight LUT, or one with piecewise linear interpolation
// in between the points.
// Jonathan Westhues, Dec 2005
//-----------------------------------------------------------------------------
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <commctrl.h>
#include "ldmicro.h"
static HWND LutDialog;
static HWND AsStringCheckbox;
static HWND CountTextbox;
static HWND DestTextbox;
static HWND IndexTextbox;
static HWND Labels[3];
static HWND StringTextbox;
static BOOL WasAsString;
static int WasCount;
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 SWORD ValuesCache[MAX_LOOK_UP_TABLE_LEN];
static LONG_PTR PrevDestProc;
static LONG_PTR PrevIndexProc;
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;
}
}
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);
}
//-----------------------------------------------------------------------------
// 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);
}
//-----------------------------------------------------------------------------
// Make the controls that are guaranteed not to move around as the count/
// as string settings change. This is different for the piecewise linear,
// 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);
}
//-----------------------------------------------------------------------------
// 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]);
}
}
//-----------------------------------------------------------------------------
// Make the controls that hold the LUT. The exact configuration of the dialog
// will depend on (a) whether the user chose table-type or string-type entry,
// 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);
}
}
//-----------------------------------------------------------------------------
// Decode a string into a look-up table; store the values in ValuesCache[],
// and update the count checkbox (which in string mode is read-only) to
// 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;
}
//-----------------------------------------------------------------------------
// Show the look-up table dialog. This one is nasty, mostly because there are
// two ways to enter a look-up table: as a table, or as a string. Presumably
// 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);
// 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);
// 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);
}

View File

@ -0,0 +1,749 @@
//-----------------------------------------------------------------------------
// 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/>.
//------
//
// Common controls in the main window. The main window consists of the drawing
// area, where the ladder diagram is displayed, plus various controls for
// scrolling, I/O list, menus.
// Jonathan Westhues, Nov 2004
//-----------------------------------------------------------------------------
#include <windows.h>
#include <commctrl.h>
#include <commdlg.h>
#include <stdio.h>
#include <stdlib.h>
#include "ldmicro.h"
// scrollbars for the ladder logic area
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;
// 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;
// listview used to maintain the list of I/O pins with symbolic names, plus
// the internal relay too
HWND IoList;
static int IoListSelectionPoint;
static BOOL IoListOutOfSync;
int IoListHeight;
int IoListTop;
// whether the simulation is running in real time
static BOOL RealTimeSimulationRunning;
//-----------------------------------------------------------------------------
// Create the standard Windows controls used in the main window: a Listview
// for the I/O list, and a status bar for settings.
//-----------------------------------------------------------------------------
void MakeMainWindowControls(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)
IoList = CreateWindowEx(WS_EX_CLIENTEDGE, WC_LISTVIEW, "", WS_CHILD |
LVS_REPORT | LVS_NOSORTHEADER | LVS_SHOWSELALWAYS | WS_TABSTOP |
LVS_SINGLESEL | WS_CLIPSIBLINGS,
12, 25, 300, 300, MainWindow, NULL, Instance, NULL);
ListView_SetExtendedListViewStyle(IoList, LVS_EX_FULLROWSELECT);
int typeWidth = 85;
int pinWidth = 100;
int portWidth = 90;
LV_ADD_COLUMN(IoList, LV_IO_NAME, 250, _("Name"));
LV_ADD_COLUMN(IoList, LV_IO_TYPE, typeWidth, _("Type"));
LV_ADD_COLUMN(IoList, LV_IO_STATE, 100, _("State"));
//LV_ADD_COLUMN(IoList, LV_IO_PIN, pinWidth, _("Pin on Processor"));
//LV_ADD_COLUMN(IoList, LV_IO_PORT, portWidth, _("MCU Port"));
HorizScrollBar = CreateWindowEx(0, WC_SCROLLBAR, "", WS_CHILD |
SBS_HORZ | SBS_BOTTOMALIGN | WS_VISIBLE | WS_CLIPSIBLINGS,
100, 100, 100, 100, MainWindow, NULL, Instance, NULL);
VertScrollBar = CreateWindowEx(0, WC_SCROLLBAR, "", WS_CHILD |
SBS_VERT | SBS_LEFTALIGN | WS_VISIBLE | WS_CLIPSIBLINGS,
200, 100, 100, 100, MainWindow, NULL, Instance, NULL);
RECT scroll;
GetWindowRect(HorizScrollBar, &scroll);
ScrollHeight = scroll.bottom - scroll.top;
GetWindowRect(VertScrollBar, &scroll);
ScrollWidth = scroll.right - scroll.left;
StatusBar = CreateStatusWindow(WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS,
"LDmicro started", MainWindow, 0);
int edges[] = { 250, 370, -1 };
SendMessage(StatusBar, SB_SETPARTS, 3, (LPARAM)edges);
ShowWindow(IoList, SW_SHOW);
}
//-----------------------------------------------------------------------------
// Set up the title bar text for the main window; indicate whether we are in
// simulation or editing mode, and indicate the filename.
//-----------------------------------------------------------------------------
void UpdateMainWindowTitleBar(void)
{
char line[MAX_PATH+100];
if(InSimulationMode) {
if(RealTimeSimulationRunning) {
strcpy(line, _("OpenPLC Ladder - Simulation (Running)"));
} else {
strcpy(line, _("OpenPLC Ladder - Simulation (Stopped)"));
}
} else {
strcpy(line, _("OpenPLC Ladder - Program Editor"));
}
if(strlen(CurrentSaveFile) > 0) {
sprintf(line+strlen(line), " - %s", CurrentSaveFile);
} else {
strcat(line, _(" - (not yet saved)"));
}
SetWindowText(MainWindow, line);
}
//-----------------------------------------------------------------------------
// Set the enabled state of the logic menu items to reflect where we are on
// the schematic (e.g. can't insert two coils in series).
//-----------------------------------------------------------------------------
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);
}
//-----------------------------------------------------------------------------
// Set the enabled state of the undo/redo menus.
//-----------------------------------------------------------------------------
void SetUndoEnabled(BOOL undoEnabled, BOOL redoEnabled)
{
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 compile, help; //settings, compile, help;
int i;
FileMenu = CreatePopupMenu();
AppendMenu(FileMenu, MF_STRING, MNU_NEW, _("&New\tCtrl+N"));
AppendMenu(FileMenu, MF_STRING, MNU_OPEN, _("&Open...\tCtrl+O"));
AppendMenu(FileMenu, MF_STRING, MNU_SAVE, _("&Save\tCtrl+S"));
AppendMenu(FileMenu, MF_STRING, MNU_SAVE_AS,_("Save &As..."));
AppendMenu(FileMenu, MF_SEPARATOR,0, "");
AppendMenu(FileMenu, MF_STRING, MNU_EXPORT,
_("&Export As Text...\tCtrl+E"));
AppendMenu(FileMenu, MF_SEPARATOR,0, "");
AppendMenu(FileMenu, MF_STRING, MNU_EXIT, _("E&xit"));
EditMenu = CreatePopupMenu();
AppendMenu(EditMenu, MF_STRING, MNU_UNDO, _("&Undo\tCtrl+Z"));
AppendMenu(EditMenu, MF_STRING, MNU_REDO, _("&Redo\tCtrl+Y"));
AppendMenu(EditMenu, MF_SEPARATOR, 0, NULL);
AppendMenu(EditMenu, MF_STRING, MNU_INSERT_RUNG_BEFORE,
_("Insert Rung &Before\tShift+6"));
AppendMenu(EditMenu, MF_STRING, MNU_INSERT_RUNG_AFTER,
_("Insert Rung &After\tShift+V"));
AppendMenu(EditMenu, MF_STRING, MNU_PUSH_RUNG_UP,
_("Move Selected Rung &Up\tShift+Up"));
AppendMenu(EditMenu, MF_STRING, MNU_PUSH_RUNG_DOWN,
_("Move Selected Rung &Down\tShift+Down"));
AppendMenu(EditMenu, MF_SEPARATOR, 0, NULL);
AppendMenu(EditMenu, MF_STRING, MNU_DELETE_ELEMENT,
_("&Delete Selected Element\tDel"));
AppendMenu(EditMenu, MF_STRING, MNU_DELETE_RUNG,
_("D&elete Rung\tShift+Del"));
InstructionMenu = CreatePopupMenu();
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_COMMENT,
_("Insert Co&mment\t;"));
AppendMenu(InstructionMenu, MF_SEPARATOR, 0, NULL);
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_CONTACTS,
_("Insert &Contacts\tC"));
AppendMenu(InstructionMenu, MF_SEPARATOR, 0, NULL);
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_OSR,
_("Insert OSR (One Shot Rising)\t&/"));
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_OSF,
_("Insert OSF (One Shot Falling)\t&\\"));
AppendMenu(InstructionMenu, MF_SEPARATOR, 0, NULL);
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_TON,
_("Insert T&ON (Delayed Turn On)\tO"));
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_TOF,
_("Insert TO&F (Delayed Turn Off)\tF"));
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_RTO,
_("Insert R&TO (Retentive Delayed Turn On)\tT"));
AppendMenu(InstructionMenu, MF_SEPARATOR, 0, NULL);
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_CTU,
_("Insert CT&U (Count Up)\tU"));
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_CTD,
_("Insert CT&D (Count Down)\tI"));
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_CTC,
_("Insert CT&C (Count Circular)\tJ"));
AppendMenu(InstructionMenu, MF_SEPARATOR, 0, NULL);
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_EQU,
_("Insert EQU (Compare for Equals)\t="));
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_NEQ,
_("Insert NEQ (Compare for Not Equals)"));
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_GRT,
_("Insert GRT (Compare for Greater Than)\t>"));
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_GEQ,
_("Insert GEQ (Compare for Greater Than or Equal)\t."));
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_LES,
_("Insert LES (Compare for Less Than)\t<"));
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_LEQ,
_("Insert LEQ (Compare for Less Than or Equal)\t,"));
AppendMenu(InstructionMenu, MF_SEPARATOR, 0, NULL);
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_OPEN,
_("Insert Open-Circuit"));
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_SHORT,
_("Insert Short-Circuit"));
//AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_MASTER_RLY,
// _("Insert Master Control Relay"));
AppendMenu(InstructionMenu, MF_SEPARATOR, 0, NULL);
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_COIL,
_("Insert Coi&l\tL"));
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_RES,
_("Insert R&ES (Counter/RTO Reset)\tE"));
AppendMenu(InstructionMenu, MF_SEPARATOR, 0, NULL);
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_MOV,
_("Insert MOV (Move)\tM"));
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_ADD,
_("Insert ADD (16-bit Integer Add)\t+"));
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_SUB,
_("Insert SUB (16-bit Integer Subtract)\t-"));
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_MUL,
_("Insert MUL (16-bit Integer Multiply)\t*"));
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_DIV,
_("Insert DIV (16-bit Integer Divide)\tD"));
/*AppendMenu(InstructionMenu, MF_SEPARATOR, 0, NULL);
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_SHIFT_REG,
_("Insert Shift Register"));
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_LUT,
_("Insert Look-Up Table"));
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_PWL,
_("Insert Piecewise Linear"));
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_FMTD_STR,
_("Insert Formatted String Over UART"));
AppendMenu(InstructionMenu, MF_SEPARATOR, 0, NULL);
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_UART_SEND,
_("Insert &UART Send"));
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_UART_RECV,
_("Insert &UART Receive"));
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_SET_PWM,
_("Insert Set PWM Output"));
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_READ_ADC,
_("Insert A/D Converter Read\tP"));
AppendMenu(InstructionMenu, MF_STRING, MNU_INSERT_PERSIST,
_("Insert Make Persistent"));
*/
AppendMenu(InstructionMenu, MF_SEPARATOR, 0, NULL);
AppendMenu(InstructionMenu, MF_STRING, MNU_MAKE_NORMAL,
_("Make Norm&al\tA"));
AppendMenu(InstructionMenu, MF_STRING, MNU_NEGATE,
_("Make &Negated\tN"));
AppendMenu(InstructionMenu, MF_STRING, MNU_MAKE_SET_ONLY,
_("Make &Set-Only\tS"));
AppendMenu(InstructionMenu, MF_STRING, MNU_MAKE_RESET_ONLY,
_("Make &Reset-Only\tR"));
/*
settings = CreatePopupMenu();
AppendMenu(settings, MF_STRING, MNU_MCU_SETTINGS, _("&MCU Parameters..."));
ProcessorMenu = CreatePopupMenu();
for(i = 0; i < NUM_SUPPORTED_MCUS; i++) {
AppendMenu(ProcessorMenu, MF_STRING, MNU_PROCESSOR_0+i,
SupportedMcus[i].mcuName);
}
AppendMenu(ProcessorMenu, MF_STRING, MNU_PROCESSOR_0+i,
_("(no microcontroller)"));
AppendMenu(settings, MF_STRING | MF_POPUP, (UINT_PTR)ProcessorMenu,
_("&Microcontroller"));
*/
SimulateMenu = CreatePopupMenu();
AppendMenu(SimulateMenu, MF_STRING, MNU_SIMULATION_MODE,
_("Si&mulation Mode\tCtrl+M"));
AppendMenu(SimulateMenu, MF_STRING | MF_GRAYED, MNU_START_SIMULATION,
_("Start &Real-Time Simulation\tCtrl+R"));
AppendMenu(SimulateMenu, MF_STRING | MF_GRAYED, MNU_STOP_SIMULATION,
_("&Halt Simulation\tCtrl+H"));
AppendMenu(SimulateMenu, MF_STRING | MF_GRAYED, MNU_SINGLE_CYCLE,
_("Single &Cycle\tSpace"));
compile = CreatePopupMenu();
AppendMenu(compile, MF_STRING, MNU_COMPILE, _("&Compile\tF5"));
AppendMenu(compile, MF_STRING, MNU_COMPILE_AS, _("Compile &As..."));
help = CreatePopupMenu();
AppendMenu(help, MF_STRING, MNU_MANUAL, _("&Manual...\tF1"));
AppendMenu(help, MF_STRING, MNU_ABOUT, _("&About..."));
TopMenu = CreateMenu();
AppendMenu(TopMenu, MF_STRING | MF_POPUP, (UINT_PTR)FileMenu, _("&File"));
AppendMenu(TopMenu, MF_STRING | MF_POPUP, (UINT_PTR)EditMenu, _("&Edit"));
/*
AppendMenu(TopMenu, MF_STRING | MF_POPUP, (UINT_PTR)settings,
_("&Settings"));
*/
AppendMenu(TopMenu, MF_STRING | MF_POPUP, (UINT_PTR)InstructionMenu,
_("&Instruction"));
AppendMenu(TopMenu, MF_STRING | MF_POPUP, (UINT_PTR)SimulateMenu,
_("Si&mulate"));
AppendMenu(TopMenu, MF_STRING | MF_POPUP, (UINT_PTR)compile,
_("&Compile"));
AppendMenu(TopMenu, MF_STRING | MF_POPUP, (UINT_PTR)help, _("&Help"));
return TopMenu;
}
//-----------------------------------------------------------------------------
// Adjust the size and visibility of the scrollbars as necessary, either due
// to a change in the size of the program or a change in the size of the
// window.
//-----------------------------------------------------------------------------
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);
}
//-----------------------------------------------------------------------------
// Respond to a WM_VSCROLL sent to the main window, presumably by the one and
// only vertical scrollbar that it has as a child.
//-----------------------------------------------------------------------------
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);
}
}
//-----------------------------------------------------------------------------
// Respond to a WM_HSCROLL sent to the main window, presumably by the one and
// only horizontal scrollbar that it has as a child.
//-----------------------------------------------------------------------------
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);
}
}
//-----------------------------------------------------------------------------
// Cause the status bar and the list view to be in sync with the actual data
// structures describing the settings and the I/O configuration. Listview
// does callbacks to get the strings it displays, so it just needs to know
// how many elements to populate.
//-----------------------------------------------------------------------------
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);
}
}
//-----------------------------------------------------------------------------
// Regenerate the I/O list, keeping the selection in the same place if
// possible.
//-----------------------------------------------------------------------------
void GenerateIoListDontLoseSelection(void)
{
int i;
IoListSelectionPoint = -1;
for(i = 0; i < Prog.io.count; i++) {
if(ListView_GetItemState(IoList, i, LVIS_SELECTED)) {
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();
}
//-----------------------------------------------------------------------------
// Called when the main window has been resized. Adjust the size of the
// status bar and the listview to reflect the new window size.
//-----------------------------------------------------------------------------
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);
}
//-----------------------------------------------------------------------------
// Toggle whether we are in simulation mode. A lot of options are only
// available in one mode or the other.
//-----------------------------------------------------------------------------
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, 4, 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, 4, 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);
}
//-----------------------------------------------------------------------------
// Start real-time simulation. Have to update the controls grayed status
// to reflect this.
//-----------------------------------------------------------------------------
void StartSimulation(void)
{
RealTimeSimulationRunning = TRUE;
EnableMenuItem(SimulateMenu, MNU_START_SIMULATION, MF_GRAYED);
EnableMenuItem(SimulateMenu, MNU_STOP_SIMULATION, MF_ENABLED);
StartSimulationTimer();
UpdateMainWindowTitleBar();
}
//-----------------------------------------------------------------------------
// Stop real-time simulation. Have to update the controls grayed status
// to reflect this.
//-----------------------------------------------------------------------------
void StopSimulation(void)
{
RealTimeSimulationRunning = FALSE;
EnableMenuItem(SimulateMenu, MNU_START_SIMULATION, MF_ENABLED);
EnableMenuItem(SimulateMenu, MNU_STOP_SIMULATION, MF_GRAYED);
KillTimer(MainWindow, TIMER_SIMULATE);
UpdateMainWindowTitleBar();
}

View File

@ -0,0 +1 @@
@nmake D=LDLANG_EN %*

View File

@ -0,0 +1,17 @@
#!/usr/bin/perl
sub SYS { system($_[0]); }
SYS("rm -rf build");
SYS("mkdir build");
for $f qw(DE ES FR IT PT TR) {
SYS("nmake clean");
SYS("nmake D=LDLANG_$f");
$fl = lc($f);
SYS("copy ldmicro.exe build\\ldmicro-$fl.exe");
}
SYS("nmake clean");
SYS("nmake D=LDLANG_EN");
SYS("copy ldmicro.exe build\\ldmicro.exe");

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,790 @@
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.
ı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ıı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>

View File

@ -0,0 +1,969 @@
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

View File

@ -0,0 +1,805 @@
//-----------------------------------------------------------------------------
// 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/>.
//------
//
// The table of supported MCUs, used to determine where the IOs are, what
// instruction set, what init code, etc.
// Jonathan Westhues, Oct 2004
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// ATmega128 or ATmega64
McuIoPinInfo AvrAtmega128_64TQFPIoPinInfo[] = {
{ 'E', 0, 2 },
{ 'E', 1, 3 },
{ 'E', 2, 4 },
{ 'E', 3, 5 },
{ 'E', 4, 6 },
{ 'E', 5, 7 },
{ 'E', 6, 8 },
{ 'E', 7, 9 },
{ 'B', 0, 10 },
{ 'B', 1, 11 },
{ 'B', 2, 12 },
{ 'B', 3, 13 },
{ 'B', 4, 14 },
{ 'B', 5, 15 },
{ 'B', 6, 16 },
{ 'B', 7, 17 },
{ 'G', 3, 18 },
{ 'G', 4, 19 },
{ 'D', 0, 25 },
{ 'D', 1, 26 },
{ 'D', 2, 27 },
{ 'D', 3, 28 },
{ 'D', 4, 29 },
{ 'D', 5, 30 },
{ 'D', 6, 31 },
{ 'D', 7, 32 },
{ 'G', 0, 33 },
{ 'G', 1, 34 },
{ 'C', 0, 35 },
{ 'C', 1, 36 },
{ 'C', 2, 37 },
{ 'C', 3, 38 },
{ 'C', 4, 39 },
{ 'C', 5, 40 },
{ 'C', 6, 41 },
{ 'C', 7, 42 },
{ 'G', 2, 43 },
{ 'A', 7, 44 },
{ 'A', 6, 45 },
{ 'A', 5, 46 },
{ 'A', 4, 47 },
{ 'A', 3, 48 },
{ 'A', 2, 49 },
{ 'A', 1, 50 },
{ 'A', 0, 51 },
{ 'F', 7, 54 },
{ 'F', 6, 55 },
{ 'F', 5, 56 },
{ 'F', 4, 57 },
{ 'F', 3, 58 },
{ 'F', 2, 59 },
{ 'F', 1, 60 },
{ 'F', 0, 61 },
};
McuAdcPinInfo AvrAtmega128_64TQFPAdcPinInfo[] = {
{ 61, 0x00 },
{ 60, 0x01 },
{ 59, 0x02 },
{ 58, 0x03 },
{ 57, 0x04 },
{ 56, 0x05 },
{ 55, 0x06 },
{ 54, 0x07 },
};
//-----------------------------------------------------------------------------
// ATmega162
McuIoPinInfo AvrAtmega162IoPinInfo[] = {
{ 'B', 0, 1 },
{ 'B', 1, 2 },
{ 'B', 2, 3 },
{ 'B', 3, 4 },
{ 'B', 4, 5 },
{ 'B', 5, 6 },
{ 'B', 6, 7 },
{ 'B', 7, 8 },
{ 'D', 0, 10 },
{ 'D', 1, 11 },
{ 'D', 2, 12 },
{ 'D', 3, 13 },
{ 'D', 4, 14 },
{ 'D', 5, 15 },
{ 'D', 6, 16 },
{ 'D', 7, 17 },
{ 'C', 0, 21 },
{ 'C', 1, 22 },
{ 'C', 2, 23 },
{ 'C', 3, 24 },
{ 'C', 4, 25 },
{ 'C', 5, 26 },
{ 'C', 6, 27 },
{ 'C', 7, 28 },
{ 'E', 2, 29 },
{ 'E', 1, 30 },
{ 'E', 0, 31 },
{ 'A', 7, 32 },
{ 'A', 6, 33 },
{ 'A', 5, 34 },
{ 'A', 4, 35 },
{ 'A', 3, 36 },
{ 'A', 2, 37 },
{ 'A', 1, 38 },
{ 'A', 0, 39 },
};
//-----------------------------------------------------------------------------
// ATmega16 or ATmega32
McuIoPinInfo AvrAtmega16or32IoPinInfo[] = {
{ 'B', 0, 1 },
{ 'B', 1, 2 },
{ 'B', 2, 3 },
{ 'B', 3, 4 },
{ 'B', 4, 5 },
{ 'B', 5, 6 },
{ 'B', 6, 7 },
{ 'B', 7, 8 },
{ 'D', 0, 14 },
{ 'D', 1, 15 },
{ 'D', 2, 16 },
{ 'D', 3, 17 },
{ 'D', 4, 18 },
{ 'D', 5, 19 },
{ 'D', 6, 20 },
{ 'D', 7, 21 },
{ 'C', 0, 22 },
{ 'C', 1, 23 },
{ 'C', 2, 24 },
{ 'C', 3, 25 },
{ 'C', 4, 26 },
{ 'C', 5, 27 },
{ 'C', 6, 28 },
{ 'C', 7, 29 },
{ 'A', 7, 33 },
{ 'A', 6, 34 },
{ 'A', 5, 35 },
{ 'A', 4, 36 },
{ 'A', 3, 37 },
{ 'A', 2, 38 },
{ 'A', 1, 39 },
{ 'A', 0, 40 },
};
McuAdcPinInfo AvrAtmega16or32AdcPinInfo[] = {
{ 40, 0x00 },
{ 39, 0x01 },
{ 38, 0x02 },
{ 37, 0x03 },
{ 36, 0x04 },
{ 35, 0x05 },
{ 34, 0x06 },
{ 33, 0x07 },
};
//-----------------------------------------------------------------------------
// ATmega8
McuIoPinInfo AvrAtmega8IoPinInfo[] = {
{ 'D', 0, 2 },
{ 'D', 1, 3 },
{ 'D', 2, 4 },
{ 'D', 3, 5 },
{ 'D', 4, 6 },
{ 'D', 5, 11 },
{ 'D', 6, 12 },
{ 'D', 7, 13 },
{ 'B', 0, 14 },
{ 'B', 1, 15 },
{ 'B', 2, 16 },
{ 'B', 3, 17 },
{ 'B', 4, 18 },
{ 'B', 5, 19 },
{ 'C', 0, 23 },
{ 'C', 1, 24 },
{ 'C', 2, 25 },
{ 'C', 3, 26 },
{ 'C', 4, 27 },
{ 'C', 5, 28 },
};
McuAdcPinInfo AvrAtmega8AdcPinInfo[] = {
{ 23, 0x00 }, // ADC0
{ 24, 0x01 },
{ 25, 0x02 },
{ 26, 0x03 },
{ 27, 0x04 },
{ 28, 0x05 }, // ADC5
};
//-----------------------------------------------------------------------------
// A variety of 18-pin PICs that share the same digital IO assignment.
McuIoPinInfo Pic18PinIoInfo[] = {
{ 'A', 2, 1 },
{ 'A', 3, 2 },
{ 'A', 4, 3 },
{ 'A', 5, 4 },
{ 'B', 0, 6 },
{ 'B', 1, 7 },
{ 'B', 2, 8 },
{ 'B', 3, 9 },
{ 'B', 4, 10 },
{ 'B', 5, 11 },
{ 'B', 6, 12 },
{ 'B', 7, 13 },
{ 'A', 6, 15 },
{ 'A', 7, 16 },
{ 'A', 0, 17 },
{ 'A', 1, 18 },
};
McuAdcPinInfo Pic16f819AdcPinInfo[] = {
{ 1, 0x02 },
{ 2, 0x03 },
{ 3, 0x04 },
{ 17, 0x00 },
{ 18, 0x01 },
};
McuAdcPinInfo Pic16f88AdcPinInfo[] = {
{ 1, 0x02 },
{ 2, 0x03 },
{ 3, 0x04 },
{ 12, 0x05 },
{ 13, 0x06 },
{ 17, 0x00 },
{ 18, 0x01 },
};
//-----------------------------------------------------------------------------
// PIC16F877
McuIoPinInfo Pic16f877IoPinInfo[] = {
{ 'A', 0, 2 },
{ 'A', 1, 3 },
{ 'A', 2, 4 },
{ 'A', 3, 5 },
{ 'A', 4, 6 },
{ 'A', 5, 7 },
{ 'E', 0, 8 },
{ 'E', 1, 9 },
{ 'E', 2, 10 },
{ 'C', 0, 15 },
{ 'C', 1, 16 },
{ 'C', 2, 17 },
{ 'C', 3, 18 },
{ 'D', 0, 19 },
{ 'D', 1, 20 },
{ 'D', 2, 21 },
{ 'D', 3, 22 },
{ 'C', 4, 23 },
{ 'C', 5, 24 },
{ 'C', 6, 25 },
{ 'C', 7, 26 },
{ 'D', 4, 27 },
{ 'D', 5, 28 },
{ 'D', 6, 29 },
{ 'D', 7, 30 },
{ 'B', 0, 33 },
{ 'B', 1, 34 },
{ 'B', 2, 35 },
{ 'B', 3, 36 },
{ 'B', 4, 37 },
{ 'B', 5, 38 },
{ 'B', 6, 39 },
{ 'B', 7, 40 },
};
McuAdcPinInfo Pic16f877AdcPinInfo[] = {
{ 2, 0x00 },
{ 3, 0x01 },
{ 4, 0x02 },
{ 5, 0x03 },
{ 7, 0x04 },
{ 8, 0x05 },
{ 9, 0x06 },
{ 10, 0x07 },
};
//-----------------------------------------------------------------------------
// PIC16F876
McuIoPinInfo Pic16f876IoPinInfo[] = {
{ 'A', 0, 2 },
{ 'A', 1, 3 },
{ 'A', 2, 4 },
{ 'A', 3, 5 },
{ 'A', 4, 6 },
{ 'A', 5, 7 },
{ 'C', 0, 11 },
{ 'C', 1, 12 },
{ 'C', 2, 13 },
{ 'C', 3, 14 },
{ 'C', 4, 15 },
{ 'C', 5, 16 },
{ 'C', 6, 17 },
{ 'C', 7, 18 },
{ 'B', 0, 21 },
{ 'B', 1, 22 },
{ 'B', 2, 23 },
{ 'B', 3, 24 },
{ 'B', 4, 25 },
{ 'B', 5, 26 },
{ 'B', 6, 27 },
{ 'B', 7, 28 },
};
McuAdcPinInfo Pic16f876AdcPinInfo[] = {
{ 2, 0x00 },
{ 3, 0x01 },
{ 4, 0x02 },
{ 5, 0x03 },
{ 7, 0x04 }
};
//-----------------------------------------------------------------------------
// PIC16F887
McuIoPinInfo Pic16f887IoPinInfo[] = {
{ 'A', 0, 2 },
{ 'A', 1, 3 },
{ 'A', 2, 4 },
{ 'A', 3, 5 },
{ 'A', 4, 6 },
{ 'A', 5, 7 },
{ 'E', 0, 8 },
{ 'E', 1, 9 },
{ 'E', 2, 10 },
{ 'C', 0, 15 },
{ 'C', 1, 16 },
{ 'C', 2, 17 },
{ 'C', 3, 18 },
{ 'D', 0, 19 },
{ 'D', 1, 20 },
{ 'D', 2, 21 },
{ 'D', 3, 22 },
{ 'C', 4, 23 },
{ 'C', 5, 24 },
{ 'C', 6, 25 },
{ 'C', 7, 26 },
{ 'D', 4, 27 },
{ 'D', 5, 28 },
{ 'D', 6, 29 },
{ 'D', 7, 30 },
{ 'B', 0, 33 },
{ 'B', 1, 34 },
{ 'B', 2, 35 },
{ 'B', 3, 36 },
{ 'B', 4, 37 },
{ 'B', 5, 38 },
{ 'B', 6, 39 },
{ 'B', 7, 40 },
};
McuAdcPinInfo Pic16f887AdcPinInfo[] = {
{ 2, 0x00 },
{ 3, 0x01 },
{ 4, 0x02 },
{ 5, 0x03 },
{ 7, 0x04 },
{ 8, 0x05 },
{ 9, 0x06 },
{ 10, 0x07 },
{ 33, 0x0c },
{ 34, 0x0a },
{ 35, 0x08 },
{ 36, 0x09 },
{ 37, 0x0b },
{ 38, 0x0d },
};
//-----------------------------------------------------------------------------
// PIC16F886
McuIoPinInfo Pic16f886IoPinInfo[] = {
{ 'A', 0, 2 },
{ 'A', 1, 3 },
{ 'A', 2, 4 },
{ 'A', 3, 5 },
{ 'A', 4, 6 },
{ 'A', 5, 7 },
{ 'C', 0, 11 },
{ 'C', 1, 12 },
{ 'C', 2, 13 },
{ 'C', 3, 14 },
{ 'C', 4, 15 },
{ 'C', 5, 16 },
{ 'C', 6, 17 },
{ 'C', 7, 18 },
{ 'B', 0, 21 },
{ 'B', 1, 22 },
{ 'B', 2, 23 },
{ 'B', 3, 24 },
{ 'B', 4, 25 },
{ 'B', 5, 26 },
{ 'B', 6, 27 },
{ 'B', 7, 28 },
};
McuAdcPinInfo Pic16f886AdcPinInfo[] = {
{ 2, 0x00 },
{ 3, 0x01 },
{ 4, 0x02 },
{ 5, 0x03 },
{ 7, 0x04 },
{ 21, 0x0c },
{ 22, 0x0a },
{ 23, 0x08 },
{ 24, 0x09 },
{ 25, 0x0b },
{ 26, 0x0d },
};
#define arraylen(x) (sizeof(x)/sizeof((x)[0]))
McuIoInfo SupportedMcus[NUM_SUPPORTED_MCUS] = {
{
"Atmel AVR ATmega128 64-TQFP",
'P',
{ 0x39, 0x36, 0x33, 0x30, 0x21, 0x20, 0x63 }, // PINx
{ 0x3b, 0x38, 0x35, 0x32, 0x23, 0x62, 0x65 }, // PORTx
{ 0x3a, 0x37, 0x34, 0x31, 0x22, 0x61, 0x64 }, // DDRx
64*1024,
{ { 0x100, 4096 } },
AvrAtmega128_64TQFPIoPinInfo,
arraylen(AvrAtmega128_64TQFPIoPinInfo),
AvrAtmega128_64TQFPAdcPinInfo,
arraylen(AvrAtmega128_64TQFPAdcPinInfo),
1023,
{ 27, 28 },
17,
ISA_AVR,
TRUE,
0
},
{
"Atmel AVR ATmega64 64-TQFP",
'P',
{ 0x39, 0x36, 0x33, 0x30, 0x21, 0x20, 0x63 }, // PINx
{ 0x3b, 0x38, 0x35, 0x32, 0x23, 0x62, 0x65 }, // PORTx
{ 0x3a, 0x37, 0x34, 0x31, 0x22, 0x61, 0x64 }, // DDRx
32*1024,
{ { 0x100, 4096 } },
AvrAtmega128_64TQFPIoPinInfo,
arraylen(AvrAtmega128_64TQFPIoPinInfo),
AvrAtmega128_64TQFPAdcPinInfo,
arraylen(AvrAtmega128_64TQFPAdcPinInfo),
1023,
{ 27, 28 },
17,
ISA_AVR,
TRUE,
0
},
{
"Atmel AVR ATmega162 40-PDIP",
'P',
{ 0x39, 0x36, 0x33, 0x30, 0x25 }, // PINx
{ 0x3b, 0x38, 0x35, 0x32, 0x27 }, // PORTx
{ 0x3a, 0x37, 0x34, 0x31, 0x26 }, // DDRx
8*1024,
{ { 0x100, 1024 } },
AvrAtmega162IoPinInfo,
arraylen(AvrAtmega162IoPinInfo),
NULL,
0,
0,
{ 0, 0 },
0,
ISA_AVR,
TRUE,
0
},
{
"Atmel AVR ATmega32 40-PDIP",
'P',
{ 0x39, 0x36, 0x33, 0x30 }, // PINx
{ 0x3b, 0x38, 0x35, 0x32 }, // PORTx
{ 0x3a, 0x37, 0x34, 0x31 }, // DDRx
16*1024,
{ { 0x60, 2048 } },
AvrAtmega16or32IoPinInfo,
arraylen(AvrAtmega16or32IoPinInfo),
AvrAtmega16or32AdcPinInfo,
arraylen(AvrAtmega16or32AdcPinInfo),
1023,
{ 14, 15 },
0,
ISA_AVR,
TRUE,
0
},
{
"Atmel AVR ATmega16 40-PDIP",
'P',
{ 0x39, 0x36, 0x33, 0x30 }, // PINx
{ 0x3b, 0x38, 0x35, 0x32 }, // PORTx
{ 0x3a, 0x37, 0x34, 0x31 }, // DDRx
8*1024,
{ { 0x60, 1024 } },
AvrAtmega16or32IoPinInfo,
arraylen(AvrAtmega16or32IoPinInfo),
AvrAtmega16or32AdcPinInfo,
arraylen(AvrAtmega16or32AdcPinInfo),
1023,
{ 14, 15 },
0,
ISA_AVR,
TRUE,
0
},
{
"Atmel AVR ATmega8 28-PDIP",
'P',
{ 0xff, 0x36, 0x33, 0x30 }, // PINx (but there is no xxxA)
{ 0xff, 0x38, 0x35, 0x32 }, // PORTx
{ 0xff, 0x37, 0x34, 0x31 }, // DDRx
4*1024,
{ { 0x60, 1024 } },
AvrAtmega8IoPinInfo,
arraylen(AvrAtmega8IoPinInfo),
AvrAtmega8AdcPinInfo,
arraylen(AvrAtmega8AdcPinInfo),
1023,
{ 2, 3 },
17,
ISA_AVR,
TRUE,
0
},
{
"Microchip PIC16F628 18-PDIP or 18-SOIC",
'R',
{ 0x05, 0x06 }, // PORTx
{ 0x05, 0x06 }, // PORTx
{ 0x85, 0x86 }, // TRISx
2048,
{ { 0x20, 96 }, { 0xa0, 80 }, { 0x120, 48 } },
Pic18PinIoInfo,
arraylen(Pic18PinIoInfo),
NULL,
0,
0,
{ 7, 8 },
0,
ISA_PIC16,
FALSE,
// code protection off, data code protection off, LVP disabled,
// BOD reset enabled, RA5/nMCLR is RA5, PWRT enabled, WDT disabled,
// HS oscillator
0x3f62
},
{
"Microchip PIC16F88 18-PDIP or 18-SOIC",
'R',
{ 0x05, 0x06 }, // PORTx
{ 0x05, 0x06 }, // PORTx
{ 0x85, 0x86 }, // TRISx
4096,
{ { 0x20, 96 }, { 0xa0, 80 }, { 0x120, 48 } },
Pic18PinIoInfo,
arraylen(Pic18PinIoInfo),
Pic16f88AdcPinInfo,
arraylen(Pic16f88AdcPinInfo),
1023,
{ 8, 11 },
0,
ISA_PIC16,
FALSE,
(1 << 13) | // CP off
(1 << 12) | // CCP on RB2 (doesn't matter)
(1 << 11) | // ICD disabled
(3 << 9) | // flash write protection off
(1 << 8) | // code protection off
(0 << 7) | // LVP disabled
(1 << 6) | // BOR enabled
(0 << 5) | // RA5/nMCLR is RA5
(0 << 4) | // for osc sel, later
(0 << 3) | // PWRT enabled
(0 << 2) | // WDT disabled
(2 << 0), // HS oscillator
},
{
"Microchip PIC16F819 18-PDIP or 18-SOIC",
'R',
{ 0x05, 0x06 }, // PORTx
{ 0x05, 0x06 }, // PORTx
{ 0x85, 0x86 }, // TRISx
2048,
{ { 0x20, 96 } },
Pic18PinIoInfo,
arraylen(Pic18PinIoInfo),
Pic16f819AdcPinInfo,
arraylen(Pic16f819AdcPinInfo),
1023,
{ 0, 0 },
0,
ISA_PIC16,
FALSE,
(1 << 13) | // code protect off
(1 << 12) | // CCP1 on RB2 (doesn't matter, can't use)
(1 << 11) | // disable debugger
(3 << 9) | // flash protection off
(1 << 8) | // data protect off
(0 << 7) | // LVP disabled
(1 << 6) | // BOR enabled
(0 << 5) | // nMCLR/RA5 is RA5
(0 << 3) | // PWRTE enabled
(0 << 2) | // WDT disabled
(2 << 0), // HS oscillator
},
{
"Microchip PIC16F877 40-PDIP",
'R',
{ 0x05, 0x06, 0x07, 0x08, 0x09 }, // PORTx
{ 0x05, 0x06, 0x07, 0x08, 0x09 }, // PORTx
{ 0x85, 0x86, 0x87, 0x88, 0x89 }, // TRISx
8*1024,
{ { 0x20, 96 }, { 0xa0, 80 }, { 0x110, 96 }, { 0x190, 96 } },
Pic16f877IoPinInfo,
arraylen(Pic16f877IoPinInfo),
Pic16f877AdcPinInfo,
arraylen(Pic16f877AdcPinInfo),
1023,
{ 26, 25 },
16,
ISA_PIC16,
FALSE,
// code protection off, debug off, flash write off, EE code protection
// off, LVP disabled, BOD enabled, CP off, PWRT enabled, WDT disabled,
// HS oscillator
0x3f72
},
{
"Microchip PIC16F876 28-PDIP or 28-SOIC",
'R',
{ 0x05, 0x06, 0x07 }, // PORTx
{ 0x05, 0x06, 0x07 }, // PORTx
{ 0x85, 0x86, 0x87 }, // TRISx
8*1024,
{ { 0x20, 96 }, { 0xa0, 80 }, { 0x110, 96 }, { 0x190, 96 } },
Pic16f876IoPinInfo,
arraylen(Pic16f876IoPinInfo),
Pic16f876AdcPinInfo,
arraylen(Pic16f876AdcPinInfo),
1023,
{ 18, 17 },
12,
ISA_PIC16,
FALSE,
// code protection off, debug off, flash write off, EE code protection
// off, LVP disabled, BOD enabled, CP off, PWRT enabled, WDT disabled,
// HS oscillator
0x3f72
},
{
"Microchip PIC16F887 40-PDIP",
'R',
{ 0x05, 0x06, 0x07, 0x08, 0x09 }, // PORTx
{ 0x05, 0x06, 0x07, 0x08, 0x09 }, // PORTx
{ 0x85, 0x86, 0x87, 0x88, 0x89 }, // TRISx
8*1024,
{ { 0x20, 96 }, { 0xa0, 80 }, { 0x120, 80 }, { 0x1a0, 80 } },
Pic16f887IoPinInfo,
arraylen(Pic16f887IoPinInfo),
Pic16f887AdcPinInfo,
arraylen(Pic16f887AdcPinInfo),
1023,
{ 26, 25 },
16,
ISA_PIC16,
FALSE,
(3 << (9+16)) | // flash write protection off
(0 << (8+16)) | // BOR at 2.1 V
(1 << 13) | // ICD disabled
(0 << 12) | // LVP disabled
(0 << 11) | // fail-safe clock monitor disabled
(0 << 10) | // internal/external switchover disabled
(3 << 8) | // brown-out detect enabled
(1 << 7) | // data code protection disabled
(1 << 6) | // code protection disabled
(1 << 5) | // nMCLR enabled
(0 << 4) | // PWRTE enabled
(0 << 3) | // WDTE disabled
(2 << 0) // HS oscillator
},
{
"Microchip PIC16F886 28-PDIP or 28-SOIC",
'R',
{ 0x05, 0x06, 0x07, 0x08, 0x09 }, // PORTx
{ 0x05, 0x06, 0x07, 0x08, 0x09 }, // PORTx
{ 0x85, 0x86, 0x87, 0x88, 0x89 }, // TRISx
8*1024,
{ { 0x20, 96 }, { 0xa0, 80 }, { 0x120, 80 }, { 0x1a0, 80 } },
Pic16f886IoPinInfo,
arraylen(Pic16f886IoPinInfo),
Pic16f886AdcPinInfo,
arraylen(Pic16f886AdcPinInfo),
1023,
{ 18, 17 },
12,
ISA_PIC16,
FALSE,
(3 << (9+16)) | // flash write protection off
(0 << (8+16)) | // BOR at 2.1 V
(1 << 13) | // ICD disabled
(0 << 12) | // LVP disabled
(0 << 11) | // fail-safe clock monitor disabled
(0 << 10) | // internal/external switchover disabled
(3 << 8) | // brown-out detect enabled
(1 << 7) | // data code protection disabled
(1 << 6) | // code protection disabled
(1 << 5) | // nMCLR enabled
(0 << 4) | // PWRTE enabled
(0 << 3) | // WDTE disabled
(2 << 0) // HS oscillator
},
{
"ANSI C Code",
'x',
{ 0x00 },
{ 0x00 },
{ 0x00 },
0,
{ { 0x00, 0 } },
NULL,
0,
NULL,
0,
0,
{ 0, 0 },
0,
ISA_ANSIC,
FALSE,
0x00
},
{
"Interpretable Byte Code",
'x',
{ 0x00 },
{ 0x00 },
{ 0x00 },
0,
{ { 0x00, 0 } },
NULL,
0,
NULL,
0,
0,
{ 0, 0 },
0,
ISA_INTERPRETED,
FALSE,
0x00
}
};

View File

@ -0,0 +1,384 @@
//-----------------------------------------------------------------------------
// 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/>.
//------
//
// Miscellaneous utility functions that don't fit anywhere else. IHEX writing,
// verified memory allocator, other junk.
//-----------------------------------------------------------------------------
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include "ldmicro.h"
// We should display messages to the user differently if we are running
// interactively vs. in batch (command-line) mode.
BOOL RunningInBatchMode = FALSE;
// Allocate memory on a local heap
HANDLE MainHeap;
// Running checksum as we build up IHEX records.
static int IhexChecksum;
// Try to common a bit of stuff between the dialog boxes, since only one
// can be open at any time.
HWND OkButton;
HWND CancelButton;
BOOL DialogDone;
BOOL DialogCancel;
HFONT MyNiceFont;
HFONT MyFixedFont;
//-----------------------------------------------------------------------------
// printf-like debug function, to the Windows debug log.
//-----------------------------------------------------------------------------
void dbp(char *str, ...)
{
va_list f;
char buf[1024];
va_start(f, str);
vsprintf(buf, str, f);
OutputDebugString(buf);
OutputDebugString("\n");
}
//-----------------------------------------------------------------------------
// Wrapper for AttachConsole that does nothing running under <WinXP, so that
// we still run (except for the console stuff) in earlier versions.
//-----------------------------------------------------------------------------
#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;
HMODULE hm = LoadLibrary("kernel32.dll");
if(!hm) return FALSE;
fp = (fptr_acd *)GetProcAddress(hm, "AttachConsole");
if(!fp) return FALSE;
return fp(base);
}
//-----------------------------------------------------------------------------
// For error messages to the user; printf-like, to a message box.
//-----------------------------------------------------------------------------
void Error(char *str, ...)
{
va_list f;
char buf[1024];
va_start(f, str);
vsprintf(buf, str, f);
if(RunningInBatchMode) {
AttachConsoleDynamic(ATTACH_PARENT_PROCESS);
HANDLE h = GetStdHandle(STD_OUTPUT_HANDLE);
DWORD written;
// Indicate that it's an error, plus the output filename
char str[MAX_PATH+100];
sprintf(str, "compile error ('%s'): ", CurrentCompileFile);
WriteFile(h, str, strlen(str), &written, NULL);
// The error message itself
WriteFile(h, buf, strlen(buf), &written, NULL);
// And an extra newline to be safe.
strcpy(str, "\n");
WriteFile(h, str, strlen(str), &written, NULL);
} else {
HWND h = GetForegroundWindow();
MessageBox(h, buf, _("LDmicro Error"), MB_OK | MB_ICONERROR);
}
}
//-----------------------------------------------------------------------------
// A standard format for showing a message that indicates that a compile
// was successful.
//-----------------------------------------------------------------------------
void CompileSuccessfulMessage(char *str)
{
if(RunningInBatchMode) {
char str[MAX_PATH+100];
sprintf(str, "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);
} else {
MessageBox(MainWindow, str, _("Compile Successful"),
MB_OK | MB_ICONINFORMATION);
}
}
//-----------------------------------------------------------------------------
// Check the consistency of the heap on which all the PLC program stuff is
// stored.
//-----------------------------------------------------------------------------
void CheckHeap(char *file, int line)
{
static unsigned int SkippedCalls;
static SDWORD LastCallTime;
SDWORD now = GetTickCount();
// It slows us down too much to do the check every time we are called;
// but let's still do the check periodically; let's do it every 70
// calls or every 20 ms, whichever is sooner.
if(SkippedCalls < 70 && (now - LastCallTime) < 20) {
SkippedCalls++;
return;
}
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();
}
}
//-----------------------------------------------------------------------------
// Like malloc/free, but memsets memory allocated to all zeros. Also TODO some
// checking and something sensible if it fails.
//-----------------------------------------------------------------------------
void *CheckMalloc(size_t n)
{
ok();
void *p = HeapAlloc(MainHeap, HEAP_ZERO_MEMORY, n);
return p;
}
void CheckFree(void *p)
{
ok();
HeapFree(MainHeap, 0, p);
}
//-----------------------------------------------------------------------------
// Clear the checksum and write the : that starts an IHEX record.
//-----------------------------------------------------------------------------
void StartIhex(FILE *f)
{
fprintf(f, ":");
IhexChecksum = 0;
}
//-----------------------------------------------------------------------------
// Write an octet in hex format to the given stream, and update the checksum
// for the IHEX file.
//-----------------------------------------------------------------------------
void WriteIhex(FILE *f, BYTE b)
{
fprintf(f, "%02X", b);
IhexChecksum += b;
}
//-----------------------------------------------------------------------------
// Write the finished checksum to the IHEX file from the running sum
// calculated by WriteIhex.
//-----------------------------------------------------------------------------
void FinishIhex(FILE *f)
{
IhexChecksum = ~IhexChecksum + 1;
IhexChecksum = IhexChecksum & 0xff;
fprintf(f, "%02X\n", IhexChecksum);
}
//-----------------------------------------------------------------------------
// Create a window with a given client area.
//-----------------------------------------------------------------------------
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);
RECT r;
GetClientRect(h, &r);
width = width - (r.right - width);
height = height - (r.bottom - height);
SetWindowPos(h, HWND_TOP, x, y, width, height, 0);
return h;
}
//-----------------------------------------------------------------------------
// Window proc for the dialog boxes. This Ok/Cancel stuff is common to a lot
// of places, and there are no other callbacks from the children.
//-----------------------------------------------------------------------------
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);
}
return 1;
}
//-----------------------------------------------------------------------------
// Set the font of a control to a pretty proportional font (typ. Tahoma).
//-----------------------------------------------------------------------------
void NiceFont(HWND h)
{
SendMessage(h, WM_SETFONT, (WPARAM)MyNiceFont, TRUE);
}
//-----------------------------------------------------------------------------
// Set the font of a control to a pretty fixed-width font (typ. Lucida
// Console).
//-----------------------------------------------------------------------------
void FixedFont(HWND h)
{
SendMessage(h, WM_SETFONT, (WPARAM)MyFixedFont, TRUE);
}
//-----------------------------------------------------------------------------
// Create our dialog box class, used for most of the popup dialogs.
//-----------------------------------------------------------------------------
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);
}
//-----------------------------------------------------------------------------
// Map an I/O type to a string describing it. Used both in the on-screen
// list and when we write a text file to describe it.
//-----------------------------------------------------------------------------
char *IoTypeToString(int ioType)
{
switch(ioType) {
case IO_TYPE_DIG_INPUT: return _("digital in");
case IO_TYPE_DIG_OUTPUT: return _("digital out");
case IO_TYPE_INTERNAL_RELAY: return _("int. relay");
case IO_TYPE_UART_TX: return _("UART tx");
case IO_TYPE_UART_RX: return _("UART rx");
case IO_TYPE_PWM_OUTPUT: return _("PWM out");
case IO_TYPE_TON: return _("turn-on delay");
case IO_TYPE_TOF: return _("turn-off delay");
case IO_TYPE_RTO: return _("retentive timer");
case IO_TYPE_COUNTER: return _("counter");
case IO_TYPE_GENERAL: return _("general var");
case IO_TYPE_READ_ADC: return _("adc input");
default: return _("<corrupt!>");
}
}
//-----------------------------------------------------------------------------
// Get a pin number for a given I/O; for digital ins and outs and analog ins,
// this is easy, but for PWM and UART this is forced (by what peripherals
// are available) so we look at the characteristics of the MCU that is in
// use.
//-----------------------------------------------------------------------------
void PinNumberForIo(char *dest, PlcProgramSingleIo *io)
{
if(!dest) return;
if(!io) {
strcpy(dest, "");
return;
}
int type = io->type;
if(type == IO_TYPE_DIG_INPUT || type == IO_TYPE_DIG_OUTPUT
|| type == IO_TYPE_READ_ADC)
{
int pin = io->pin;
if(pin == NO_PIN_ASSIGNED) {
strcpy(dest, _("(not assigned)"));
} else {
sprintf(dest, "%d", pin);
}
} else if(type == IO_TYPE_UART_TX && Prog.mcu) {
if(Prog.mcu->uartNeeds.txPin == 0) {
strcpy(dest, _("<no UART!>"));
} else {
sprintf(dest, "%d", Prog.mcu->uartNeeds.txPin);
}
} else if(type == IO_TYPE_UART_RX && Prog.mcu) {
if(Prog.mcu->uartNeeds.rxPin == 0) {
strcpy(dest, _("<no UART!>"));
} else {
sprintf(dest, "%d", Prog.mcu->uartNeeds.rxPin);
}
} else if(type == IO_TYPE_PWM_OUTPUT && Prog.mcu) {
if(Prog.mcu->pwmNeedsPin == 0) {
strcpy(dest, _("<no PWM!>"));
} else {
sprintf(dest, "%d", Prog.mcu->pwmNeedsPin);
}
} else {
strcpy(dest, "");
}
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,332 @@
/* This is auto-generated code from LDmicro. Do not edit this file! Go
back to the ladder diagram source for changes in the logic, and make
any C additions either in ladder.h or in additional .c files linked
against this one. */
/* You must provide ladder.h; there you must provide:
* a typedef for SWORD and BOOL, signed 16 bit and boolean types
(probably typedef signed short SWORD; typedef unsigned char BOOL;)
You must also provide implementations of all the I/O read/write
either as inlines in the header file or in another source file. (The
I/O functions are all declared extern.)
See the generated source code (below) for function names. */
#include "ladder.h"
/* Define EXTERN_EVERYTHING in ladder.h if you want all symbols extern.
This could be useful to implement `magic variables,' so that for
example when you write to the ladder variable duty_cycle, your PLC
runtime can look at the C variable U_duty_cycle and use that to set
the PWM duty cycle on the micro. That way you can add support for
peripherals that LDmicro doesn't know about. */
#ifdef EXTERN_EVERYTHING
#define STATIC
#else
#define STATIC static
#endif
/* Define NO_PROTOTYPES if you don't want LDmicro to provide prototypes for
all the I/O functions (Read_U_xxx, Write_U_xxx) that you must provide.
If you define this then you must provide your own prototypes for these
functions in ladder.h, or provide definitions (e.g. as inlines or macros)
for them in ladder.h. */
#ifdef NO_PROTOTYPES
#define PROTO(x)
#else
#define PROTO(x) x
#endif
/* U_xxx symbols correspond to user-defined names. There is such a symbol
for every internal relay, variable, timer, and so on in the ladder
program. I_xxx symbols are internally generated. */
STATIC BOOL I_b_mcr = 0;
#define Read_I_b_mcr() I_b_mcr
#define Write_I_b_mcr(x) I_b_mcr = x
STATIC BOOL I_b_rung_top = 0;
#define Read_I_b_rung_top() I_b_rung_top
#define Write_I_b_rung_top(x) I_b_rung_top = x
STATIC BOOL U_b_Rosc = 0;
#define Read_U_b_Rosc() U_b_Rosc
#define Write_U_b_Rosc(x) U_b_Rosc = x
STATIC BOOL I_b_Tof_antiglitch = 0;
#define Read_I_b_Tof_antiglitch() I_b_Tof_antiglitch
#define Write_I_b_Tof_antiglitch(x) I_b_Tof_antiglitch = x
STATIC SWORD U_i_Tof = 0;
STATIC SWORD U_i_Ton = 0;
/* You provide this function. */
PROTO(extern BOOL Read_U_b_Xup(void);)
STATIC BOOL I_b_oneShot_0000 = 0;
#define Read_I_b_oneShot_0000() I_b_oneShot_0000
#define Write_I_b_oneShot_0000(x) I_b_oneShot_0000 = x
STATIC SWORD U_i_Ccnt = 0;
STATIC SWORD U_i_Trto = 0;
/* You provide these functions. */
PROTO(BOOL Read_U_b_Yup(void);)
PROTO(void Write_U_b_Yup(BOOL v);)
/* You provide this function. */
PROTO(extern BOOL Read_U_b_Xdown(void);)
STATIC BOOL I_b_oneShot_0001 = 0;
#define Read_I_b_oneShot_0001() I_b_oneShot_0001
#define Write_I_b_oneShot_0001(x) I_b_oneShot_0001 = x
STATIC SWORD I_i_scratch = 0;
/* You provide these functions. */
PROTO(BOOL Read_U_b_Ydown(void);)
PROTO(void Write_U_b_Ydown(BOOL v);)
/* You provide this function. */
PROTO(extern BOOL Read_U_b_Xres(void);)
STATIC BOOL I_b_parOut_0000 = 0;
#define Read_I_b_parOut_0000() I_b_parOut_0000
#define Write_I_b_parOut_0000(x) I_b_parOut_0000 = x
STATIC BOOL I_b_parThis_0000 = 0;
#define Read_I_b_parThis_0000() I_b_parThis_0000
#define Write_I_b_parThis_0000(x) I_b_parThis_0000 = x
STATIC BOOL I_b_scratch = 0;
#define Read_I_b_scratch() I_b_scratch
#define Write_I_b_scratch(x) I_b_scratch = x
STATIC BOOL I_b_oneShot_0002 = 0;
#define Read_I_b_oneShot_0002() I_b_oneShot_0002
#define Write_I_b_oneShot_0002(x) I_b_oneShot_0002 = x
STATIC BOOL I_b_oneShot_0003 = 0;
#define Read_I_b_oneShot_0003() I_b_oneShot_0003
#define Write_I_b_oneShot_0003(x) I_b_oneShot_0003 = x
STATIC BOOL I_b_oneShot_0004 = 0;
#define Read_I_b_oneShot_0004() I_b_oneShot_0004
#define Write_I_b_oneShot_0004(x) I_b_oneShot_0004 = x
STATIC SWORD U_i_Ccirc = 0;
STATIC SWORD I_i_scratch2 = 0;
STATIC BOOL I_b_oneShot_0005 = 0;
#define Read_I_b_oneShot_0005() I_b_oneShot_0005
#define Write_I_b_oneShot_0005(x) I_b_oneShot_0005 = x
STATIC BOOL I_b_Tpulse_antiglitch = 0;
#define Read_I_b_Tpulse_antiglitch() I_b_Tpulse_antiglitch
#define Write_I_b_Tpulse_antiglitch(x) I_b_Tpulse_antiglitch = x
STATIC SWORD U_i_Tpulse = 0;
/* You provide these functions. */
PROTO(BOOL Read_U_b_Ypulse(void);)
PROTO(void Write_U_b_Ypulse(BOOL v);)
/* Call this function once per PLC cycle. You are responsible for calling
it at the interval that you specified in the MCU configuration when you
generated this code. */
void PlcCycle(void)
{
Write_I_b_mcr(1);
/* start rung 2 */
Write_I_b_rung_top(Read_I_b_mcr());
/* start series [ */
if(!Read_U_b_Rosc()) {
Write_I_b_rung_top(0);
}
if(!Read_I_b_Tof_antiglitch()) {
U_i_Tof = 1;
}
Write_I_b_Tof_antiglitch(1);
if(!Read_I_b_rung_top()) {
if(U_i_Tof < 1) {
U_i_Tof++;
Write_I_b_rung_top(1);
}
} else {
U_i_Tof = 0;
}
if(Read_I_b_rung_top()) {
if(U_i_Ton < 1) {
U_i_Ton++;
Write_I_b_rung_top(0);
}
} else {
U_i_Ton = 0;
}
if(Read_I_b_rung_top()) {
Write_U_b_Rosc(0);
} else {
Write_U_b_Rosc(1);
}
/* ] finish series */
/* start rung 3 */
Write_I_b_rung_top(Read_I_b_mcr());
/* start series [ */
if(!Read_U_b_Rosc()) {
Write_I_b_rung_top(0);
}
if(!Read_U_b_Xup()) {
Write_I_b_rung_top(0);
}
if(Read_I_b_rung_top()) {
if(!Read_I_b_oneShot_0000()) {
U_i_Ccnt++;
}
}
Write_I_b_oneShot_0000(Read_I_b_rung_top());
if(U_i_Ccnt < 20) {
Write_I_b_rung_top(0);
} else {
Write_I_b_rung_top(1);
}
if(U_i_Trto < 199) {
if(Read_I_b_rung_top()) {
U_i_Trto++;
}
Write_I_b_rung_top(0);
} else {
Write_I_b_rung_top(1);
}
Write_U_b_Yup(Read_I_b_rung_top());
/* ] finish series */
/* start rung 4 */
Write_I_b_rung_top(Read_I_b_mcr());
/* start series [ */
if(!Read_U_b_Rosc()) {
Write_I_b_rung_top(0);
}
if(!Read_U_b_Xdown()) {
Write_I_b_rung_top(0);
}
if(Read_I_b_rung_top()) {
if(!Read_I_b_oneShot_0001()) {
I_i_scratch = 1;
U_i_Ccnt = U_i_Ccnt - I_i_scratch;
}
}
Write_I_b_oneShot_0001(Read_I_b_rung_top());
if(U_i_Ccnt < 10) {
Write_I_b_rung_top(0);
} else {
Write_I_b_rung_top(1);
}
Write_U_b_Ydown(Read_I_b_rung_top());
/* ] finish series */
/* start rung 5 */
Write_I_b_rung_top(Read_I_b_mcr());
/* start series [ */
if(!Read_U_b_Xres()) {
Write_I_b_rung_top(0);
}
/* start parallel [ */
Write_I_b_parOut_0000(0);
Write_I_b_parThis_0000(Read_I_b_rung_top());
Write_I_b_scratch(Read_I_b_parThis_0000());
if(Read_I_b_oneShot_0002()) {
Write_I_b_parThis_0000(0);
}
Write_I_b_oneShot_0002(Read_I_b_scratch());
if(Read_I_b_parThis_0000()) {
Write_I_b_parOut_0000(1);
}
Write_I_b_parThis_0000(Read_I_b_rung_top());
Write_I_b_scratch(Read_I_b_parThis_0000());
if(!Read_I_b_parThis_0000()) {
if(Read_I_b_oneShot_0003()) {
Write_I_b_parThis_0000(1);
}
} else {
Write_I_b_parThis_0000(0);
}
Write_I_b_oneShot_0003(Read_I_b_scratch());
if(Read_I_b_parThis_0000()) {
Write_I_b_parOut_0000(1);
}
Write_I_b_rung_top(Read_I_b_parOut_0000());
/* ] finish parallel */
if(Read_I_b_rung_top()) {
U_i_Trto = 0;
}
/* ] finish series */
/* start rung 6 */
Write_I_b_rung_top(Read_I_b_mcr());
/* start series [ */
if(!Read_U_b_Rosc()) {
Write_I_b_rung_top(0);
}
if(Read_I_b_rung_top()) {
if(!Read_I_b_oneShot_0004()) {
U_i_Ccirc++;
if(U_i_Ccirc < 8) {
} else {
U_i_Ccirc = 0;
}
}
}
Write_I_b_oneShot_0004(Read_I_b_rung_top());
/* ] finish series */
/* start rung 7 */
Write_I_b_rung_top(Read_I_b_mcr());
/* start series [ */
I_i_scratch2 = 3;
if(U_i_Ccirc == I_i_scratch2) {
} else {
Write_I_b_rung_top(0);
}
Write_I_b_scratch(Read_I_b_rung_top());
if(!Read_I_b_rung_top()) {
if(Read_I_b_oneShot_0005()) {
Write_I_b_rung_top(1);
}
} else {
Write_I_b_rung_top(0);
}
Write_I_b_oneShot_0005(Read_I_b_scratch());
if(!Read_I_b_Tpulse_antiglitch()) {
U_i_Tpulse = 3;
}
Write_I_b_Tpulse_antiglitch(1);
if(!Read_I_b_rung_top()) {
if(U_i_Tpulse < 3) {
U_i_Tpulse++;
Write_I_b_rung_top(1);
}
} else {
U_i_Tpulse = 0;
}
Write_U_b_Ypulse(Read_I_b_rung_top());
/* ] finish series */
}

View File

@ -0,0 +1,332 @@
/* This is auto-generated code from LDmicro. Do not edit this file! Go
back to the ladder diagram source for changes in the logic, and make
any C additions either in ladder.h or in additional .c files linked
against this one. */
/* You must provide ladder.h; there you must provide:
* a typedef for SWORD and BOOL, signed 16 bit and boolean types
(probably typedef signed short SWORD; typedef unsigned char BOOL;)
You must also provide implementations of all the I/O read/write
either as inlines in the header file or in another source file. (The
I/O functions are all declared extern.)
See the generated source code (below) for function names. */
#include "ladder.h"
/* Define EXTERN_EVERYTHING in ladder.h if you want all symbols extern.
This could be useful to implement `magic variables,' so that for
example when you write to the ladder variable duty_cycle, your PLC
runtime can look at the C variable U_duty_cycle and use that to set
the PWM duty cycle on the micro. That way you can add support for
peripherals that LDmicro doesn't know about. */
#ifdef EXTERN_EVERYTHING
#define STATIC
#else
#define STATIC static
#endif
/* Define NO_PROTOTYPES if you don't want LDmicro to provide prototypes for
all the I/O functions (Read_U_xxx, Write_U_xxx) that you must provide.
If you define this then you must provide your own prototypes for these
functions in ladder.h, or provide definitions (e.g. as inlines or macros)
for them in ladder.h. */
#ifdef NO_PROTOTYPES
#define PROTO(x)
#else
#define PROTO(x) x
#endif
/* U_xxx symbols correspond to user-defined names. There is such a symbol
for every internal relay, variable, timer, and so on in the ladder
program. I_xxx symbols are internally generated. */
STATIC BOOL I_b_mcr = 0;
#define Read_I_b_mcr() I_b_mcr
#define Write_I_b_mcr(x) I_b_mcr = x
STATIC BOOL I_b_rung_top = 0;
#define Read_I_b_rung_top() I_b_rung_top
#define Write_I_b_rung_top(x) I_b_rung_top = x
STATIC BOOL U_b_Rosc = 0;
#define Read_U_b_Rosc() U_b_Rosc
#define Write_U_b_Rosc(x) U_b_Rosc = x
STATIC BOOL I_b_Tof_antiglitch = 0;
#define Read_I_b_Tof_antiglitch() I_b_Tof_antiglitch
#define Write_I_b_Tof_antiglitch(x) I_b_Tof_antiglitch = x
STATIC SWORD U_i_Tof = 0;
STATIC SWORD U_i_Ton = 0;
/* You provide this function. */
PROTO(extern BOOL Read_U_b_Xup(void);)
STATIC BOOL I_b_oneShot_0000 = 0;
#define Read_I_b_oneShot_0000() I_b_oneShot_0000
#define Write_I_b_oneShot_0000(x) I_b_oneShot_0000 = x
STATIC SWORD U_i_Ccnt = 0;
STATIC SWORD U_i_Trto = 0;
/* You provide these functions. */
PROTO(BOOL Read_U_b_Yup(void);)
PROTO(void Write_U_b_Yup(BOOL v);)
/* You provide this function. */
PROTO(extern BOOL Read_U_b_Xdown(void);)
STATIC BOOL I_b_oneShot_0001 = 0;
#define Read_I_b_oneShot_0001() I_b_oneShot_0001
#define Write_I_b_oneShot_0001(x) I_b_oneShot_0001 = x
STATIC SWORD I_i_scratch = 0;
/* You provide these functions. */
PROTO(BOOL Read_U_b_Ydown(void);)
PROTO(void Write_U_b_Ydown(BOOL v);)
/* You provide this function. */
PROTO(extern BOOL Read_U_b_Xres(void);)
STATIC BOOL I_b_parOut_0000 = 0;
#define Read_I_b_parOut_0000() I_b_parOut_0000
#define Write_I_b_parOut_0000(x) I_b_parOut_0000 = x
STATIC BOOL I_b_parThis_0000 = 0;
#define Read_I_b_parThis_0000() I_b_parThis_0000
#define Write_I_b_parThis_0000(x) I_b_parThis_0000 = x
STATIC BOOL I_b_scratch = 0;
#define Read_I_b_scratch() I_b_scratch
#define Write_I_b_scratch(x) I_b_scratch = x
STATIC BOOL I_b_oneShot_0002 = 0;
#define Read_I_b_oneShot_0002() I_b_oneShot_0002
#define Write_I_b_oneShot_0002(x) I_b_oneShot_0002 = x
STATIC BOOL I_b_oneShot_0003 = 0;
#define Read_I_b_oneShot_0003() I_b_oneShot_0003
#define Write_I_b_oneShot_0003(x) I_b_oneShot_0003 = x
STATIC BOOL I_b_oneShot_0004 = 0;
#define Read_I_b_oneShot_0004() I_b_oneShot_0004
#define Write_I_b_oneShot_0004(x) I_b_oneShot_0004 = x
STATIC SWORD U_i_Ccirc = 0;
STATIC SWORD I_i_scratch2 = 0;
STATIC BOOL I_b_oneShot_0005 = 0;
#define Read_I_b_oneShot_0005() I_b_oneShot_0005
#define Write_I_b_oneShot_0005(x) I_b_oneShot_0005 = x
STATIC BOOL I_b_Tpulse_antiglitch = 0;
#define Read_I_b_Tpulse_antiglitch() I_b_Tpulse_antiglitch
#define Write_I_b_Tpulse_antiglitch(x) I_b_Tpulse_antiglitch = x
STATIC SWORD U_i_Tpulse = 0;
/* You provide these functions. */
PROTO(BOOL Read_U_b_Ypulse(void);)
PROTO(void Write_U_b_Ypulse(BOOL v);)
/* Call this function once per PLC cycle. You are responsible for calling
it at the interval that you specified in the MCU configuration when you
generated this code. */
void PlcCycle(void)
{
Write_I_b_mcr(1);
/* start rung 2 */
Write_I_b_rung_top(Read_I_b_mcr());
/* start series [ */
if(!Read_U_b_Rosc()) {
Write_I_b_rung_top(0);
}
if(!Read_I_b_Tof_antiglitch()) {
U_i_Tof = 1;
}
Write_I_b_Tof_antiglitch(1);
if(!Read_I_b_rung_top()) {
if(U_i_Tof < 1) {
U_i_Tof++;
Write_I_b_rung_top(1);
}
} else {
U_i_Tof = 0;
}
if(Read_I_b_rung_top()) {
if(U_i_Ton < 1) {
U_i_Ton++;
Write_I_b_rung_top(0);
}
} else {
U_i_Ton = 0;
}
if(Read_I_b_rung_top()) {
Write_U_b_Rosc(0);
} else {
Write_U_b_Rosc(1);
}
/* ] finish series */
/* start rung 3 */
Write_I_b_rung_top(Read_I_b_mcr());
/* start series [ */
if(!Read_U_b_Rosc()) {
Write_I_b_rung_top(0);
}
if(!Read_U_b_Xup()) {
Write_I_b_rung_top(0);
}
if(Read_I_b_rung_top()) {
if(!Read_I_b_oneShot_0000()) {
U_i_Ccnt++;
}
}
Write_I_b_oneShot_0000(Read_I_b_rung_top());
if(U_i_Ccnt < 20) {
Write_I_b_rung_top(0);
} else {
Write_I_b_rung_top(1);
}
if(U_i_Trto < 199) {
if(Read_I_b_rung_top()) {
U_i_Trto++;
}
Write_I_b_rung_top(0);
} else {
Write_I_b_rung_top(1);
}
Write_U_b_Yup(Read_I_b_rung_top());
/* ] finish series */
/* start rung 4 */
Write_I_b_rung_top(Read_I_b_mcr());
/* start series [ */
if(!Read_U_b_Rosc()) {
Write_I_b_rung_top(0);
}
if(!Read_U_b_Xdown()) {
Write_I_b_rung_top(0);
}
if(Read_I_b_rung_top()) {
if(!Read_I_b_oneShot_0001()) {
I_i_scratch = 1;
U_i_Ccnt = U_i_Ccnt - I_i_scratch;
}
}
Write_I_b_oneShot_0001(Read_I_b_rung_top());
if(U_i_Ccnt < 10) {
Write_I_b_rung_top(0);
} else {
Write_I_b_rung_top(1);
}
Write_U_b_Ydown(Read_I_b_rung_top());
/* ] finish series */
/* start rung 5 */
Write_I_b_rung_top(Read_I_b_mcr());
/* start series [ */
if(!Read_U_b_Xres()) {
Write_I_b_rung_top(0);
}
/* start parallel [ */
Write_I_b_parOut_0000(0);
Write_I_b_parThis_0000(Read_I_b_rung_top());
Write_I_b_scratch(Read_I_b_parThis_0000());
if(Read_I_b_oneShot_0002()) {
Write_I_b_parThis_0000(0);
}
Write_I_b_oneShot_0002(Read_I_b_scratch());
if(Read_I_b_parThis_0000()) {
Write_I_b_parOut_0000(1);
}
Write_I_b_parThis_0000(Read_I_b_rung_top());
Write_I_b_scratch(Read_I_b_parThis_0000());
if(!Read_I_b_parThis_0000()) {
if(Read_I_b_oneShot_0003()) {
Write_I_b_parThis_0000(1);
}
} else {
Write_I_b_parThis_0000(0);
}
Write_I_b_oneShot_0003(Read_I_b_scratch());
if(Read_I_b_parThis_0000()) {
Write_I_b_parOut_0000(1);
}
Write_I_b_rung_top(Read_I_b_parOut_0000());
/* ] finish parallel */
if(Read_I_b_rung_top()) {
U_i_Trto = 0;
}
/* ] finish series */
/* start rung 6 */
Write_I_b_rung_top(Read_I_b_mcr());
/* start series [ */
if(!Read_U_b_Rosc()) {
Write_I_b_rung_top(0);
}
if(Read_I_b_rung_top()) {
if(!Read_I_b_oneShot_0004()) {
U_i_Ccirc++;
if(U_i_Ccirc < 8) {
} else {
U_i_Ccirc = 0;
}
}
}
Write_I_b_oneShot_0004(Read_I_b_rung_top());
/* ] finish series */
/* start rung 7 */
Write_I_b_rung_top(Read_I_b_mcr());
/* start series [ */
I_i_scratch2 = 3;
if(U_i_Ccirc == I_i_scratch2) {
} else {
Write_I_b_rung_top(0);
}
Write_I_b_scratch(Read_I_b_rung_top());
if(!Read_I_b_rung_top()) {
if(Read_I_b_oneShot_0005()) {
Write_I_b_rung_top(1);
}
} else {
Write_I_b_rung_top(0);
}
Write_I_b_oneShot_0005(Read_I_b_scratch());
if(!Read_I_b_Tpulse_antiglitch()) {
U_i_Tpulse = 3;
}
Write_I_b_Tpulse_antiglitch(1);
if(!Read_I_b_rung_top()) {
if(U_i_Tpulse < 3) {
U_i_Tpulse++;
Write_I_b_rung_top(1);
}
} else {
U_i_Tpulse = 0;
}
Write_U_b_Ypulse(Read_I_b_rung_top());
/* ] finish series */
}

View File

@ -0,0 +1,330 @@
:1000000022C0189518951895189518951895189553
:100010001895189518951895189518951895189578
:100020001895189518951895189518951895189568
:100030001895189518951895189518951895189558
:10004000189518951895B0E0AEE500E10C93B0E076
:10005000ADE50FEF0C93B1E1A0E000E020E030E16E
:10006000A150B0400C93215030402223C9F73323D4
:10007000B9F7B0E0A8E900E00C93B0E0A9E907E621
:100080000C93B0E0AAE908E10C93B0E0AAE300E029
:100090000C93B0E0ABE300E00C93B0E0A7E300E822
:1000A0000C93B0E0A8E300E00C93B0E0A4E300E020
:1000B0000C93B0E0A5E300E00C93B0E0A1E308E00E
:1000C0000C93B0E0A2E300E00C93B0E0A2E200E009
:1000D0000C93B0E0A3E201E00C93B0E0A1E600E0F5
:1000E0000C93B0E0A2E600E00C93B0E0A4E600E0E0
:1000F0000C93B0E0A5E600E00C93B0E0AFE400E0C4
:100100000C93B0E0AEE409E00C93B0E0ABE40CE992
:100110000C93B0E0AAE40EE30C93B0E0A7E500E195
:100120000C93B0E0A6E50C9104FFFBCFB0E0A6E590
:100130000C9100610C93A895B1E0A1E00C910260D4
:100140000C93B1E0A1E00C91B1E0A1E01C9101FFA2
:100150001B7F01FD14601C93B1E0A1E00C9102FF34
:10016000EFC0B1E0A1E00C9103FD60C0B1E0A1E0FF
:100170000C910F7E0C93B0E0ACE30C9101FD23C019
:10018000B1E0A1E00C9100FF23C0B0E0AEE30C9120
:10019000B0E0AFE31C91039509F413951C93B0E014
:1001A000AEE30C93B1E0A0E00C91B0E0ADE30C93B2
:1001B000B0E0ACE304E00C9306E00C93B1E0A1E006
:1001C0000C910E7F0C93B1E0A1E00C9100610C93B7
:1001D000B1E0A1E00C9104FD29C0B1E0A1E00C91D7
:1001E00008600C93B0E0AFE300E00C93B0E0AEE346
:1001F00000E00C93B0E0ACE301E00C93B0E0ADE3C1
:100200000C91B1E0A2E00C93B0E0AFE300E00C93FE
:10021000B0E0AEE301E00C93B0E0ACE301E00C939E
:10022000B0E0ADE30C91B1E0A3E00C93B1E0A1E04C
:100230000C910F7E0C93B0E0ACE30C9101FD23C058
:10024000B1E0A1E00C9100FF23C0B0E0AEE30C915F
:10025000B0E0AFE31C91039509F413951C93B0E053
:10026000AEE30C93B1E0A0E00C91B0E0ADE30C93F1
:10027000B0E0ACE304E00C9306E00C93B1E0A1E045
:100280000C910E7F0C93B1E0A1E00C9100610C93F6
:10029000B1E0A1E00C9104FD53C0B0E0AFE300E099
:1002A0000C93B0E0AEE300E00C93B0E0ACE301E00F
:1002B0000C93B0E0ADE30C91B1E0A4E00C93B0E09E
:1002C000AFE300E00C93B0E0AEE301E00C93B0E0EC
:1002D000ACE301E00C93B0E0ADE30C91B1E0A5E03C
:1002E0000C93B1E0A4E00C91B1E0A5E01C91B1E069
:1002F000A2E02C91B1E0A3E03C910217130709F4AE
:100300001FC0B1E0A1E00C9101600C93B1E0A3E04B
:100310000C91B1E0A0E00C93B0E0AFE300E00C93EF
:10032000B0E0AEE300E00C93B1E0A2E00C91B0E0ED
:10033000ADE30C93B0E0ACE304E00C9306E00C9367
:10034000B1E0A1E00C91B1E0A1E01C9101FF1B7FA5
:1003500001FD14601C93B1E0A1E00C9102FF1DC0EF
:10036000B0E0A7E200E00C93B0E0A6E205E80C9351
:10037000B0E0A6E205EC0C93B0E0A6E20C9106FD1D
:10038000FBCFB0E0A4E20C91B1E0A6E00C93B0E0AA
:10039000A5E20C91B1E0A7E00C93B1E0A1E00C91D3
:1003A000B1E0A1E01C9101FF1B7F01FD14601C93D3
:1003B000B1E0A1E00C910F7D0C93B1E0A1E00C91B4
:1003C000B1E0A1E01C9102FF1F7B02FD10641C93B1
:1003D000B0E0A1E20C9100FD05C0B1E0A1E00C91FC
:1003E0000F7B0C93B1E0A1E00C9106FF05C0B1E0DA
:1003F000A1E00C9100620C93B1E0A1E00C91B1E09E
:10040000A1E01C9102FF1F7B02FD10641C93B1E070
:10041000A8E000E00C93B1E0A9E002E00C93B1E0A9
:10042000A8E00C91B1E0A9E01C91B1E0A6E02C910C
:10043000B1E0A7E03C91201731072CF4B1E0A1E036
:100440000C910F7B0C93B1E0A1E00C9106FF05C06D
:10045000B1E0A1E00C9100620C93B1E0A1E00C913D
:10046000B1E0A1E01C9105FF1B7F05FD14601C930A
:10047000B1E0A1E00C91B1E0A1E01C9102FF1F7E70
:1004800002FD10611C93B1E0A1E00C9107FF05C0D3
:10049000B1E0A1E00C910B7F0C93B1E0A1E00C91D5
:1004A000B1E0A1E01C9104FF1F7704FD10681C93CC
:1004B000B1E0A1E00C9102FF1CC0B1E0A8E001E0B6
:1004C0000C93B1E0A9E000E00C93B1E0A2E02C9124
:1004D000B1E0A3E03C91B1E0A8E00C91B1E0A9E06B
:1004E0001C91200F311FB1E0A2E02C93B1E0A3E0FA
:1004F0003C93B1E0A1E00C91B1E0A1E01C9101FFBF
:100500001B7F01FD14601C93B1E0AAE00C910E7FEB
:100510000C93B1E0A1E00C91B1E0AAE01C9102FFC4
:100520001D7F02FD12601C93B1E0A8E00AE00C936D
:10053000B1E0A9E000E00C93B1E0A8E00C91B1E0DB
:10054000A9E01C91B1E0A2E02C91B1E0A3E03C91C4
:10055000201731070CF405C0B1E0AAE00C910D7F23
:100560000C93B1E0AAE00C9101FF08C0B1E0ABE050
:1005700004E10C93B1E0ACE000E00C93B1E0AAE040
:100580000C9101FF05C0B1E0AAE00C9101600C9351
:10059000B1E0A1E00C91B1E0AAE01C9102FF1D7F47
:1005A00002FD12601C93B1E0A8E00AE00C93B1E0F8
:1005B000A9E000E00C93B1E0A8E00C91B1E0A9E063
:1005C0001C91B1E0A2E02C91B1E0A3E03C91201796
:1005D00031072CF4B1E0AAE00C910D7F0C93B1E04F
:1005E000AAE00C9101FF08C0B1E0ABE002E30C937C
:1005F000B1E0ACE000E00C93B1E0AAE00C9101FFA7
:1006000005C0B1E0AAE00C9101600C93B1E0A1E05B
:100610000C91B1E0AAE01C9102FF1D7F02FD126067
:100620001C93B1E0AAE00C9101FF21C0B1E0ABE066
:100630000C9110E030E02FEFEAE0FAE00995132F7B
:10064000022F30E024E6EBE1FAE00995B0E0A3E404
:100650000C93B1E0AAE00C9102FD09C0B1E0AAE060
:100660000C9104600C93B0E0A5E40AE60C93B1E0B1
:10067000AAE00C9101FF05C0B1E0AAE00C91016075
:100680000C93B1E0AAE00C91B1E0A1E01C9100FF55
:100690001B7F00FD14601C93B1E0A1E00C91B1E060
:1006A000A1E01C9101FF1B7F01FD14601C93B1E0D0
:1006B000A1E00C9102FF1EC0B1E0ADE00C91B1E0F1
:1006C000AEE01C9123E630E00217130794F4B1E08A
:1006D000ADE00C91B1E0AEE01C91039509F41395E7
:1006E0001C93B1E0ADE00C93B1E0A1E00C910B7F65
:1006F0000C9308C0B1E0ADE000E00C93B1E0AEE0D7
:1007000000E00C93B1E0A1E00C91B1E0A1E01C91FC
:1007100002FF1F7E02FD10611C93B1E0AAE00C9164
:1007200003FF05C0B1E0A1E00C910B7F0C93B1E099
:10073000A1E00C91B1E0AAE01C9104FF177F04FD39
:1007400018601C93B1E0A1E00C9102FF0DC0B1E074
:10075000AAE00C9104FD08C0B1E0AFE000E00C930A
:10076000B1E0A0E100E00C93B1E0A1E00C91B1E0B8
:10077000AAE01C9102FF1F7E02FD10611C93B1E0F4
:10078000AFE00C91B1E0A1E10C93B1E0A0E10C91DC
:10079000B1E0A2E10C93B1E0AFE00C91B1E0A0E1D7
:1007A0001C9120E130E0021713070CF408C0B1E0FF
:1007B000A1E10FEF0C93B1E0A2E10FEF0C93B1E0D8
:1007C000A1E00C910F7E0C93B1E0A1E00C9104FF2D
:1007D00006C0B1E0A4E00C91B0E0ACE90C93B1E04C
:1007E000A1E00C910F7E0C93B0E0ABE90C9105FDFC
:1007F00005C0B1E0A1E00C9100610C93B1E0A1E073
:100800000C9104FF08C0B1E0A1E10FEF0C93B1E03F
:10081000A2E10FEF0C93B1E0A4E000E00C93B1E093
:10082000A5E000E00C93B1E0A4E00C91B1E0A5E0FC
:100830001C91B1E0A1E12C91B1E0A2E13C91021741
:10084000130741F4B1E0A8E003E70C93B1E0A9E09D
:1008500000E00C93B1E0A4E001E00C93B1E0A5E06E
:1008600000E00C93B1E0A4E00C91B1E0A5E01C9194
:10087000B1E0A1E12C91B1E0A2E13C910217130794
:1008800041F4B1E0A8E001E60C93B1E0A9E000E09A
:100890000C93B1E0A4E002E00C93B1E0A5E000E02D
:1008A0000C93B1E0A4E00C91B1E0A5E01C91B1E0A3
:1008B000A1E12C91B1E0A2E13C910217130741F4B0
:1008C000B1E0A8E006E70C93B1E0A9E000E00C93EA
:1008D000B1E0A4E003E00C93B1E0A5E000E00C93EC
:1008E000B1E0A4E00C91B1E0A5E01C91B1E0A1E180
:1008F0002C91B1E0A2E13C910217130741F4B1E061
:10090000A8E005E60C93B1E0A9E000E00C93B1E0AB
:10091000A4E004E00C93B1E0A5E000E00C93B1E0AA
:10092000A4E00C91B1E0A5E01C91B1E0A1E12C9113
:10093000B1E0A2E13C910217130741F4B1E0A8E055
:1009400004E60C93B1E0A9E000E00C93B1E0A4E070
:1009500005E00C93B1E0A5E000E00C93B1E0A4E069
:100960000C91B1E0A5E01C91B1E0A1E12C91B1E0C6
:10097000A2E13C910217130741F4B1E0A8E000E2C4
:100980000C93B1E0A9E000E00C93B1E0A4E006E034
:100990000C93B1E0A5E000E00C93B1E0A4E00C9171
:1009A000B1E0A5E01C91B1E0A1E12C91B1E0A2E1A0
:1009B0003C910217130741F4B1E0A8E00DE30C935A
:1009C000B1E0A9E000E00C93B1E0A4E007E00C93F3
:1009D000B1E0A5E000E00C93B1E0A4E00C91B1E03F
:1009E000A5E01C91B1E0A1E12C91B1E0A2E13C9124
:1009F0000217130741F4B1E0A8E000E20C93B1E064
:100A0000A9E000E00C93B1E0A4E008E00C93B1E0B1
:100A1000A5E000E00C93B1E0A1E00C910F7E0C93F7
:100A2000B1E0A4E00C91B1E0A5E01C91B1E0A1E13E
:100A30002C91B1E0A2E13C910217130729F4B1E037
:100A4000A1E00C9100610C93B1E0A1E00C9104FFD6
:100A500043C0B1E0A2E00C91B1E0A3E10C93B1E09E
:100A6000A3E00C91B1E0A4E10C93B1E0A8E000E2B6
:100A70000C93B1E0A9E000E00C93B1E0A2E00C918E
:100A8000B1E0A3E01C9120E030E00217130724F549
:100A9000B1E0A8E00DE20C93B1E0A9E000E00C9316
:100AA000B1E0A4E000E00C93B1E0A5E000E00C931D
:100AB000B1E0A4E02C91B1E0A5E03C91B1E0A2E06E
:100AC0000C91B1E0A3E01C91201B310BB1E0A3E13C
:100AD0002C93B1E0A4E13C93B1E0A4E009E00C93D5
:100AE000B1E0A5E000E00C93B1E0A1E00C910F7E35
:100AF0000C93B1E0A4E00C91B1E0A5E01C91B1E051
:100B0000A1E12C91B1E0A2E13C910217130729F475
:100B1000B1E0A1E00C9100610C93B1E0A1E00C9177
:100B200004FF89C0B1E0AAE00C9100620C93B1E02F
:100B3000A4E000E10C93B1E0A5E007E20C93B1E082
:100B4000A4E02C91B1E0A5E03C91B1E0A3E10C91CF
:100B5000B1E0A4E11C91EBE1FAE00995B1E0A8E075
:100B60000C93B1E0A9E01C93B1E0A4E02C91B1E0BA
:100B7000A5E03C91B1E0A8E00C91B1E0A9E01C91A6
:100B8000EAE0FAE00995B1E0A4E02C93B1E0A5E039
:100B90003C93B1E0A3E12C91B1E0A4E13C91B1E040
:100BA000A4E00C91B1E0A5E01C91201B310BB1E059
:100BB000A3E12C93B1E0A4E13C93B1E0A4E000E315
:100BC0000C93B1E0A5E000E00C93B1E0A8E02C911B
:100BD000B1E0A9E03C91B1E0A4E00C91B1E0A5E066
:100BE0001C91200F311FB1E0A8E02C93B1E0A9E0E7
:100BF0003C93B1E0A4E00C91B1E0A5E01C91B1E020
:100C0000A8E02C91B1E0A9E03C910217130771F420
:100C1000B1E0AAE00C9105FF08C0B1E0A8E000E255
:100C20000C93B1E0A9E000E00C9305C0B1E0AAE0AC
:100C30000C910F7D0C93B1E0A4E00AE00C93B1E0BD
:100C4000A5E000E00C93B1E0A1E00C910F7E0C93C5
:100C5000B1E0A4E00C91B1E0A5E01C91B1E0A1E10C
:100C60002C91B1E0A2E13C910217130729F4B1E005
:100C7000A1E00C9100610C93B1E0A1E00C9104FFA4
:100C800084C0B1E0A4E008EE0C93B1E0A5E003E07D
:100C90000C93B1E0A4E02C91B1E0A5E03C91B1E06F
:100CA000A3E10C91B1E0A4E11C91EBE1FAE009951C
:100CB000B1E0A8E00C93B1E0A9E01C93B1E0A4E09E
:100CC0002C91B1E0A5E03C91B1E0A8E00C91B1E03D
:100CD000A9E01C91EAE0FAE00995B1E0A4E02C93C8
:100CE000B1E0A5E03C93B1E0A3E12C91B1E0A4E137
:100CF0003C91B1E0A4E00C91B1E0A5E01C91201B77
:100D0000310BB1E0A3E12C93B1E0A4E13C93B1E05D
:100D1000A4E000E30C93B1E0A5E000E00C93B1E0A7
:100D2000A8E02C91B1E0A9E03C91B1E0A4E00C91E5
:100D3000B1E0A5E01C91200F311FB1E0A8E02C9399
:100D4000B1E0A9E03C93B1E0A4E00C91B1E0A5E0F2
:100D50001C91B1E0A8E02C91B1E0A9E03C91021710
:100D6000130771F4B1E0AAE00C9105FF08C0B1E0EF
:100D7000A8E000E20C93B1E0A9E000E00C9305C00C
:100D8000B1E0AAE00C910F7D0C93B1E0A4E00BE080
:100D90000C93B1E0A5E000E00C93B1E0A1E00C9170
:100DA0000F7E0C93B1E0A4E00C91B1E0A5E01C91A2
:100DB000B1E0A1E12C91B1E0A2E13C91021713074F
:100DC00029F4B1E0A1E00C9100610C93B1E0A1E045
:100DD0000C9104FF84C0B1E0A4E004E60C93B1E000
:100DE000A5E000E00C93B1E0A4E02C91B1E0A5E017
:100DF0003C91B1E0A3E10C91B1E0A4E11C91EBE1E5
:100E0000FAE00995B1E0A8E00C93B1E0A9E01C93E9
:100E1000B1E0A4E02C91B1E0A5E03C91B1E0A8E004
:100E20000C91B1E0A9E01C91EAE0FAE00995B1E08B
:100E3000A4E02C93B1E0A5E03C93B1E0A3E12C91B8
:100E4000B1E0A4E13C91B1E0A4E00C91B1E0A5E0F7
:100E50001C91201B310BB1E0A3E12C93B1E0A4E184
:100E60003C93B1E0A4E000E30C93B1E0A5E000E026
:100E70000C93B1E0A8E02C91B1E0A9E03C91B1E085
:100E8000A4E00C91B1E0A5E01C91200F311FB1E06E
:100E9000A8E02C93B1E0A9E03C93B1E0A4E00C9170
:100EA000B1E0A5E01C91B1E0A8E02C91B1E0A9E08F
:100EB0003C910217130771F4B1E0AAE00C9105FF11
:100EC00008C0B1E0A8E000E20C93B1E0A9E000E0C6
:100ED0000C9305C0B1E0AAE00C910F7D0C93B1E03A
:100EE000A4E00CE00C93B1E0A5E000E00C93B1E0CD
:100EF000A1E00C910F7E0C93B1E0A4E00C91B1E065
:100F0000A5E01C91B1E0A1E12C91B1E0A2E13C91FE
:100F10000217130729F4B1E0A1E00C9100610C93D2
:100F2000B1E0A1E00C9104FF84C0B1E0A4E00AE0CC
:100F30000C93B1E0A5E000E00C93B1E0A4E02C91AB
:100F4000B1E0A5E03C91B1E0A3E10C91B1E0A4E1F6
:100F50001C91EBE1FAE00995B1E0A8E00C93B1E057
:100F6000A9E01C93B1E0A4E02C91B1E0A5E03C9194
:100F7000B1E0A8E00C91B1E0A9E01C91EAE0FAE050
:100F80000995B1E0A4E02C93B1E0A5E03C93B1E079
:100F9000A3E12C91B1E0A4E13C91B1E0A4E00C917B
:100FA000B1E0A5E01C91201B310BB1E0A3E12C9333
:100FB000B1E0A4E13C93B1E0A4E000E30C93B1E024
:100FC000A5E000E00C93B1E0A8E02C91B1E0A9E02D
:100FD0003C91B1E0A4E00C91B1E0A5E01C91200FA0
:100FE000311FB1E0A8E02C93B1E0A9E03C93B1E05F
:100FF000A4E00C91B1E0A5E01C91B1E0A8E02C9137
:10100000B1E0A9E03C910217130771F4B1E0AAE046
:101010000C9105FF08C0B1E0A8E000E20C93B1E03C
:10102000A9E000E00C9305C0B1E0AAE00C910F7DAF
:101030000C93B1E0A4E00DE00C93B1E0A5E000E07A
:101040000C93B1E0A1E00C910F7E0C93B1E0A4E011
:101050000C91B1E0A5E01C91B1E0A1E12C91B1E0CF
:10106000A2E13C910217130729F4B1E0A1E00C9131
:1010700000610C93B1E0A1E00C9104FF62C0B1E00B
:10108000A4E001E00C93B1E0A5E000E00C93B1E036
:10109000A4E02C91B1E0A5E03C91B1E0A3E10C917A
:1010A000B1E0A4E11C91EBE1FAE00995B1E0A8E020
:1010B0000C93B1E0A9E01C93B1E0A4E02C91B1E065
:1010C000A5E03C91B1E0A8E00C91B1E0A9E01C9151
:1010D000EAE0FAE00995B1E0A4E02C93B1E0A5E0E4
:1010E0003C93B1E0A3E12C91B1E0A4E13C91B1E0EB
:1010F000A4E00C91B1E0A5E01C91201B310BB1E004
:10110000A3E12C93B1E0A4E13C93B1E0A4E000E3BF
:101110000C93B1E0A5E000E00C93B1E0A8E02C91C5
:10112000B1E0A9E03C91B1E0A4E00C91B1E0A5E010
:101130001C91200F311FB1E0A8E02C93B1E0A9E091
:101140003C93B1E0A4E00EE00C93B1E0A5E000E038
:101150000C93B1E0A4E00C91B1E0A5E01C91B1E0EA
:10116000A1E12C91B1E0A2E13C910217130741F4F7
:10117000B1E0A8E00DE00C93B1E0A9E000E00C9331
:10118000B1E0A4E00FE00C93B1E0A5E000E00C9327
:10119000B1E0A4E00C91B1E0A5E01C91B1E0A1E1C7
:1011A0002C91B1E0A2E13C910217130741F4B1E0A8
:1011B000A8E00AE00C93B1E0A9E000E00C93B1E0F4
:1011C000A1E10C91B1E0A2E11C9120E030E0021716
:1011D00013070CF42CC0B1E0A1E00C9100610C935A
:1011E000B1E0A1E00C9104FF06C0B1E0A8E00C91D1
:1011F000B0E0ACE90C93B1E0A1E00C910F7E0C9350
:10120000B0E0ABE90C9105FD05C0B1E0A1E00C91A7
:1012100000610C93B1E0AFE00C91B1E0A0E11C9152
:10122000039509F413951C93B1E0AFE00C93B1E082
:10123000A1E00C910B7F0C93B1E0AFE00C91B1E019
:10124000A0E11C9120E130E0021713072CF4B1E07B
:10125000A1E00C9104600C93B1E0A1E00C91B1E02D
:10126000A1E01C9101FF1B7F01FD14601C93B1E004
:10127000A1E00C9102FF08C0B1E0A5E108E70C93E2
:10128000B1E0A6E100E00C93B1E0A1E00C91B1E087
:10129000A1E01C9101FF1B7F01FD14601C93B1E0D4
:1012A000A1E00C9102FF1EC0B1E0A7E10C91B1E0FA
:1012B000A8E11C9127EC30E00217130794F4B1E089
:1012C000A7E10C91B1E0A8E11C91039509F41395F5
:1012D0001C93B1E0A7E10C93B1E0A1E00C910B7F6E
:1012E0000C9308C0B1E0A7E100E00C93B1E0A8E1E5
:1012F00000E00C93B1E0A1E00C91B1E0A1E01C9101
:1013000002FF1F7E02FD10611C93B1E0AAE00C9168
:1013100006FF05C0B1E0A1E00C910B7F0C93B1E09A
:10132000A1E00C91B1E0AAE01C9104FF1F7B04FD39
:1013300010641C93B1E0A1E00C9102FF06C0B1E083
:10134000A5E10C91B0E0ACE90C93B1E0A1E00C9107
:101350000B7F0C93B0E0ABE90C9105FD05C0B1E04B
:10136000A1E00C9104600C93B1E0A1E00C91B1E01C
:10137000A1E01C9101FF1B7F01FD14601C93B1E0F3
:10138000A1E00C9102FF19C0B1E0A1E00C910B7F2C
:101390000C93B0E0ABE90C9107FF0FC0B1E0A1E006
:1013A0000C9104600C93B0E0ACE90C91B1E0A9E1C0
:1013B0000C93B1E0AAE100E00C93B1E0A8E001E6F3
:1013C0000C93B1E0A9E000E00C93B1E0A9E10C912D
:1013D000B1E0AAE11C91B1E0A8E02C91B1E0A9E054
:1013E0003C910217130709F405C0B1E0A1E00C918C
:1013F0000B7F0C93B1E0A1E00C9102FF08C0B1E0BB
:10140000A2E000E00C93B1E0A3E000E00C93E1E97E
:10141000F0E00994551B441B60E110F4400F511F8C
:1014200020FD401B20FD510B55954795379527957D
:101430006A9599F70895D12ED32617FF04C0109509
:1014400000950F5F1F4F37FF04C0309520952F5F29
:101450003F4FEE24FF1841E1001F111F4A9539F458
:10146000D7FE04C0109500950F5F1F4F0895EE1C26
:10147000FF1CE21AF30A20F4E20EF31E8894ECCF6C
:041480000894EACF13
:00000001FF

View File

@ -0,0 +1,21 @@
:020000040000FA
:100000008A110A1208280000000000000000000009
:10001000283084005830A0008001840AA00B0C28EE
:10002000103095002730960000308E0000308F0091
:10003000013090000B309700831686309F008312AA
:10004000003085008316DF30850083120030860083
:100050008316FF3086008312003087008316FC3041
:10006000870083120C1D32280C116400A914A918F2
:100070002915A91C291105183E2829112919071429
:10008000291D0710A9182915A91C2911A911291919
:100090002916291D291285184E282912291E512892
:1000A000A91529192916291D2912051958282912B7
:1000B000291E5B28A915A9192915A91D2911291D72
:1000C00062288516A9182915A91C291185196928DE
:1000D0002911051E6C282911A91229192917291D72
:1000E0002913291F74288512291F7728A916291971
:1000F0002917291D2913291F7F2887108028871475
:10010000291F8328A916A91A2915A91E29118A01B0
:02011000322893
:02400E00723FFF
:00000001FF

View File

@ -0,0 +1,134 @@
:1000000022C0189518951895189518951895189553
:100010001895189518951895189518951895189578
:100020001895189518951895189518951895189568
:100030001895189518951895189518951895189558
:10004000189518951895B0E0AEE504E00C93B0E073
:10005000ADE50FEF0C93B5E0A0E000E020E034E068
:10006000A150B0400C93215030402223C9F73323D4
:10007000B9F7B0E0AAE304E00C93B0E0ABE300E032
:100080000C93B0E0A7E300E00C93B0E0A8E301E03C
:100090000C93B0E0A4E300E00C93B0E0A5E300E033
:1000A0000C93B0E0A1E300E40C93B0E0A2E300E025
:1000B0000C93B0E0A6E200E00C93B0E0A7E200E011
:1000C0000C93B0E0AFE400E00C93B0E0AEE40AE0E3
:1000D0000C93B0E0ABE404EF0C93B0E0AAE402E2CE
:1000E0000C93B0E0A9E500E40C93B0E0A8E50C9116
:1000F00006FFFBCFB0E0A8E50C9100640C93A89537
:10010000B1E0A1E00C9102600C93B1E0A1E00C9190
:10011000B1E0A1E01C9101FF1B7F01FD14601C9365
:10012000B1E0A1E00C91077F0C93B1E0A1E00C914C
:10013000B1E0A1E01C9102FF1F7E02FD10611C9343
:10014000B0E0A6E30C9100FD05C0B1E0A1E00C9188
:100150000F7E0C93B1E0A1E00C9104FF08C0B1E068
:10016000A2E00BE20C93B1E0A3E005E00C93B1E058
:10017000A1E00C9104FF05C0B1E0A1E00C91086082
:100180000C93B1E0A1E00C91B1E0A1E01C9102FF61
:100190001F7E02FD10611C93B0E0A6E30C9100FFEE
:1001A00005C0B1E0A1E00C910F7E0C93B1E0A1E09D
:1001B0000C9104FF08C0B1E0A2E004EF0C93B1E0A1
:1001C000A3E00FEF0C93B1E0A1E00C9104FF05C098
:1001D000B1E0A1E00C9108600C93B1E0A1E00C91BA
:1001E000B1E0A1E01C9103FF1B7F03FD14601C9391
:1001F000B1E0A1E00C91B1E0A1E01C9101FF1B7FF7
:1002000001FD14601C93B1E0A1E00C910F7D0C93F3
:10021000B1E0A1E00C91B1E0A1E01C9102FF1F7BD5
:1002200002FD10641C93B1E0A1E00C9106FF1CC01C
:10023000B1E0A4E008EE0C93B1E0A5E003E00C937C
:10024000B1E0A2E02C91B1E0A3E03C91B1E0A4E0E8
:100250000C91B1E0A5E01C91200F311FB1E0A6E0A8
:100260002C93B1E0A7E03C93B1E0A1E00C9106FF34
:1002700005C0B1E0A1E00C9100620C93B1E0A1E0F7
:100280000C91B1E0A1E01C9102FF1F7B02FD106404
:100290001C93B1E0A1E00C9106FF1CC0B1E0A4E00A
:1002A00005E00C93B1E0A5E000E00C93B1E0A2E022
:1002B0002C91B1E0A3E03C91B1E0A4E00C91B1E05D
:1002C000A5E01C91201B310BB1E0A8E02C93B1E01C
:1002D000A9E03C93B1E0A1E00C9106FF05C0B1E0BC
:1002E000A1E00C9100620C93B1E0A1E00C91B1E0AF
:1002F000A1E01C9102FF1F7B02FD10641C93B1E082
:10030000A1E00C9106FF1DC0B1E0A4E003E00C9356
:10031000B1E0A5E000E00C93B1E0A2E02C91B1E0E7
:10032000A3E03C91B1E0A4E00C91B1E0A5E01C9108
:10033000ECEEF3E00995B1E0AAE02C93B1E0ABE07C
:100340003C93B1E0A1E00C9106FF05C0B1E0A1E053
:100350000C9100620C93B1E0A1E00C91B1E0A1E03E
:100360001C9102FF1F7B02FD10641C93B1E0A1E011
:100370000C9106FF1DC0B1E0A4E003E00C93B1E0D6
:10038000A5E000E00C93B1E0A4E02C91B1E0A5E081
:100390003C91B1E0AAE00C91B1E0ABE01C91EDEF33
:1003A000F3E00995B1E0ACE00C93B1E0ADE01C9353
:1003B000B1E0A1E00C9106FF05C0B1E0A1E00C9115
:1003C00000620C93B1E0A1E00C91B1E0A1E01C91BE
:1003D00005FF1B7F05FD14601C93B1E0A1E00C91AB
:1003E000B1E0A1E01C9101FF1B7F01FD14601C9393
:1003F000B1E0A1E00C910F770C93B1E0A1E00C917A
:10040000B1E0AEE01C9102FF1E7F02FD11601C9363
:10041000B1E0A4E00BE20C93B1E0A5E005E00C93A1
:10042000B1E0A2E00C91B1E0A3E01C91B1E0A4E046
:100430002C91B1E0A5E03C910217130709F405C027
:10044000B1E0AEE00C910E7F0C93B1E0AEE00C9108
:1004500000FF05C0B1E0A1E00C9100680C93B1E091
:10046000A1E00C91B1E0AEE01C9102FF1E7F02FD05
:1004700011601C93B1E0AEE00C9100FF05C0B1E04B
:10048000A1E00C9100680C93B1E0A1E00C91B1E007
:10049000A1E01C9107FF1B7F07FD14601C93B1E0D6
:1004A000AEE00C910D7F0C93B1E0A1E00C91B1E0B6
:1004B000AEE01C9102FF1B7F02FD14601C93B1E0B3
:1004C000A4E000E00C93B1E0A5E000E00C93B1E003
:1004D000A4E00C91B1E0A5E01C91B1E0A6E02C9164
:1004E000B1E0A7E03C91201731070CF405C0B1E062
:1004F000AEE00C910B7F0C93B1E0AEE00C9102FFEB
:1005000005C0B1E0AEE00C9102600C93B1E0A1E057
:100510000C91B1E0AEE01C9102FF1B7F02FD146064
:100520001C93B1E0A4E006E20C93B1E0A5E005E085
:100530000C93B1E0A8E00C91B1E0A9E01C91B1E00E
:10054000A4E02C91B1E0A5E03C91201731072CF4F8
:10055000B1E0AEE00C910B7F0C93B1E0AEE00C91FA
:1005600002FF05C0B1E0AEE00C9102600C93B1E077
:10057000A1E00C91B1E0AEE01C9102FF1B7F02FDF7
:1005800014601C93B1E0AEE00C9102FF05C0B1E035
:10059000AEE00C9102600C93B1E0AEE00C91B1E0E2
:1005A000A1E01C9101FF1B7F01FD14601C93B1E0D1
:1005B000AEE00C91077F0C93B1E0A1E00C91B1E0AB
:1005C000AEE01C9102FF1F7E02FD10611C93B1E0A2
:1005D000A4E000E20C93B1E0A5E00EE40C93B1E0DE
:1005E000A6E00C91B1E0A7E01C91B1E0A4E02C9151
:1005F000B1E0A5E03C91201731070CF405C0B1E053
:10060000AEE00C910F7E0C93B1E0AEE00C9104FFD4
:1006100005C0B1E0AEE00C9108600C93B1E0A1E040
:100620000C91B1E0AEE01C9102FF1F7E02FD106153
:100630001C93B1E0A4E001E80C93B1E0A5E00FE069
:100640000C93B1E0A4E00C91B1E0A5E01C91B1E005
:10065000AAE02C91B1E0ABE03C91201731072CF4DB
:10066000B1E0AEE00C910F7E0C93B1E0AEE00C91E6
:1006700004FF05C0B1E0AEE00C9108600C93B1E05E
:10068000A1E00C91B1E0AEE01C9102FF1F7E02FDE3
:1006900010611C93B1E0AEE00C910F7E0C93B1E0C1
:1006A000AEE00C9104FF05C0B1E0AEE00C91086033
:1006B0000C93B1E0AEE00C91B1E0A1E01C9103FF1E
:1006C0001B7F03FD14601C93B1E0A1E00C91B0E02E
:1006D000ABE31C9102FF1B7F02FD14601C93B1E091
:1006E000A1E00C91B1E0A1E01C9101FF1B7F01FD95
:1006F00014601C93B1E0A4E00CED0C93B1E0A5E014
:100700000FEF0C93B1E0AAE00C91B1E0ABE01C91CB
:10071000B1E0A4E02C91B1E0A5E03C9102171307F1
:1007200029F4B1E0A1E00C910B7F0C93B1E0A4E0BF
:1007300000E00C93B1E0A5E000E00C93B1E0A2E092
:100740000C91B1E0A3E01C91B1E0A4E02C91B1E0E8
:10075000A5E03C91201731070CF405C0B1E0A1E001
:100760000C910B7F0C93B1E0A1E00C9102FF1EC035
:10077000B1E0AFE00C91B1E0A0E11C9123E130E0E9
:100780000217130794F4B1E0AFE00C91B1E0A0E1DF
:100790001C91039509F413951C93B1E0AFE00C9301
:1007A000B1E0A1E00C910B7F0C9308C0B1E0AFE089
:1007B00000E00C93B1E0A0E100E00C93B1E0A1E017
:1007C0000C91B0E0A2E31C9102FF1F7B02FD1064BC
:1007D0001C93E5E7F0E00994551B441B60E110F41D
:1007E000400F511F20FD401B20FD510B5595479593
:1007F000379527956A9599F70895D12ED32617FF37
:1008000004C0109500950F5F1F4F37FF04C030954F
:1008100020952F5F3F4FEE24FF1841E1001F111F6D
:100820004A9539F4D7FE04C0109500950F5F1F4F0D
:100830000895EE1CFF1CE21AF30A20F4E20EF31EE8
:080840008894ECCF0894EACF84
:00000001FF

View File

@ -0,0 +1,69 @@
:020000040000FA
:100000008A110A1208280000000000000000000009
:10001000283084005830A0008001840AA00B0C28EE
:10002000103095002730960000308E0000308F0091
:10003000013090000B309700831686309F008312AA
:10004000003085008316FD30850083120030860065
:100050008316FF3086008312003087008316FD3040
:10006000870083120C1D32280C116400A914A918F2
:100070002915A91C291105183E282911A91842285B
:10008000A91446282919A914291DA910A918291548
:10009000A91C2911A9194D282911291D64280030EE
:1000A0002B0203195A28A00020092B05A006A01B2B
:1000B0005F28632831302A02031C5F286328AA0FB7
:1000C0006228AB0A291168280030AA000030AB0072
:1000D000291A6E283130AC000030AD0029162919DC
:1000E000862800302D0203197C28A00020092D0548
:1000F000A006A01B8128852831302C02031C8128F2
:100100008528AC0F8428AD0A29158A280030AC0058
:100110000030AD00291D8E28A9118F28A915A91816
:100120002915A91C2911A91996282911291DB228B8
:10013000A91AB2283008AE003108AF003208B0006A
:100140003308B1003408B2003508B3003608B400F3
:100150003708B5003808B6003908B7003A08B800C3
:100160003B08B9002919A916291DA912A918291592
:10017000A91C291129132919A917291DA913A91F78
:10018000D82851309F00831680309F00831206309C
:10019000A100A10BC9281F151F19CC281E08BD00DE
:1001A00083161E088312BC00831686309F008312BC
:1001B000A91FDB2829172919A917291DA913A91F68
:1001C000E5283C08BA003D08BB00A91FE82829170C
:1001D000291B2915291F2911A9182915A91C29111D
:1001E0003E102919BE14291DBE10A919F828BE10E9
:1001F000BE1C14293E191429BF0FFF28C00A003065
:10020000400203190A29A00020094005A006A01BEE
:100210000F29102905303F02031C0F29102914292A
:100220000030BF000030C000BE183E15BE1C3E119D
:10023000BE1C1B293E142919BE14291DBE10BE1C4C
:1002400071290030C1000030C2003F084102031D87
:10025000312940084202031D31290A30C300003011
:10026000C4000130C1000030C2003F084102031D3C
:10027000412940084202031D41294630C300003095
:10028000C4000230C1000030C2003F084102031D1B
:10029000512940084202031D51295030C30000304B
:1002A000C4000330C1000030C2003F084102031DFA
:1002B000612940084202031D61294630C300003015
:1002C000C4000430C1000030C2003F084102031DD9
:1002D000712940084202031D71290A30C300003011
:1002E000C400BE1C74293E142919BE14291DBE1059
:1002F000BE1C9E294308A000A1016430A200A301F6
:1003000001308A00BB2101308A002308A1002208A5
:10031000A0006430A200A30101308A00D221013084
:100320008A0020089B00BE199E29BE1583166330E3
:10033000920083120C309D0004309200BE1CA12953
:100340003E143E1829153E1C2911A9182915A91C6F
:100350002911A918AD29A914B1292919A914291DF0
:10036000A910A9182915A91C291129198514291DB5
:1003700085108A013228A501A4010310A30CA20C48
:100380001030A600031CCA292008A4070318A50AD8
:100390002108A5070310A50CA40CA30CA20CA60B06
:1003A000C229080021082306A700A31FDC29A209EF
:1003B000A309A20A0319A30AA11FE329A009A109FD
:1003C000A00A0319A10AA501A40103101130A60077
:1003D000A00DA10DA6030319012AA40DA50D220845
:1003E000A402031CA5032308A502A51FFF292208B8
:1003F000A4070318A50A2308A5070310E829031476
:10040000E829A71F0800A009A109A00A0319A10A49
:020410000800E2
:02400E00723FFF
:00000001FF

Some files were not shown because too many files have changed in this diff Show More