Difference between revisions of "Meta:Samples/Software"

From TSG Doc
Jump to navigation Jump to search
 
(61 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<!-- Introduction. What does this software do? Whom is it for? -->
+
{{Infobox software
Introduction.
+
| name                  = Software name
 +
| logo                  = placeholder.png
 +
| screenshot            =
 +
| caption                = Software version X.X running on Windows X
 +
| developer              =
 +
| released              = <!-- {{Start date and age|YYYY|MM|DD|df=yes}} -->
 +
| discontinued          =
 +
| latest release version =
 +
| latest release date    = <!-- {{Start date and age|YYYY|MM|DD|df=yes}} -->
 +
| latest preview version =
 +
| latest preview date    = <!-- {{Start date and age|YYYY|MM|DD|df=yes}} -->
 +
| installed version      =
 +
| installed version date = <!-- {{Start date and age|YYYY|MM|DD|df=yes}} -->
 +
| status                = Active
 +
| programming language  = Ruby
 +
| operating system      = Microsoft Windows, Linux, MacOSX
 +
| platform              =
 +
| size                  =
 +
| language              =
 +
| genre                  =
 +
| license                = [http://creativecommons.org/licenses/by-sa/4.0/ Creative Commons Attribution-ShareAlike 4.0]
 +
| website                = [https://about.gitlab.com/ www.gitlab.nl]
 +
| resources              =
 +
  {{Infobox tsg
 +
    | child              = yes
 +
    | downloads          = {{bulleted list
 +
        | [http://www.ru.nl Some Download link]
 +
        | [http://www.ru.nl Some other Download link]
 +
    }}
 +
    | manuals            = {{bulleted list
 +
        | [http://www.ru.nl Quick start guide]
 +
    }}
 +
  }}
 +
}}
 +
 
 +
Introduction. What does this software do? Who are the intended users?
  
 
<!-- Table of Contents will be generated here -->
 
<!-- Table of Contents will be generated here -->
Line 6: Line 41:
 
==Features==
 
==Features==
 
This software is made to do this, it has these unique selling points:
 
This software is made to do this, it has these unique selling points:
* Feature 1<ref>Some reference</ref>
+
* Feature 1
 
* Feature 2
 
* Feature 2
 
* Feature 3
 
* Feature 3
Line 14: Line 49:
 
* Intel Core 2 Duo E8600 or higher.
 
* Intel Core 2 Duo E8600 or higher.
 
* Python
 
* Python
 
  
 
==Installation==
 
==Installation==
 
 
===Windows 7 64-bit===
 
===Windows 7 64-bit===
 
#Step 1
 
#Step 1
 
#Step 2
 
#Step 2
 
#Step 3
 
#Step 3
 
  
 
==Configuration==
 
==Configuration==
 
General settings.
 
General settings.
 +
For CMD commands, you can use this format:<br/>
 +
{{cmdline|ping 127.0.0.1 -n 50 -l 1024}}
  
 +
=== License ===
 +
License setup.
  
 
==Usage==
 
==Usage==
 
Templates and how-to's go here.
 
Templates and how-to's go here.
  
 
+
===Python===
===Template===
 
  
 
<syntaxhighlight lang="python" line>
 
<syntaxhighlight lang="python" line>
import time
+
#In the syntaxhighlight tag, change lang value to desired language.  
from ctypes import windll, byref, c_char, Structure, WinError, POINTER, WINFUNCTYPE
+
#For the list of supported languages, see http://www.mediawiki.org/wiki/Extension:SyntaxHighlight_GeSHi#Supported_languages
from ctypes.wintypes import BOOL, HMONITOR, HDC, RECT, LPARAM, DWORD, BYTE, WCHAR, HANDLE
 
 
 
 
 
_MONITORENUMPROC = WINFUNCTYPE(BOOL, HMONITOR, HDC, POINTER(RECT), LPARAM)
 
 
 
class _PHYSICAL_MONITOR(Structure):
 
_fields_ = [('handle', HANDLE), ('description', WCHAR * 128)]
 
 
 
 
 
def _iter_physical_monitors(close_handles=True):
 
"""Iterates physical monitors.
 
 
 
The handles are closed automatically whenever the iterator is advanced.
 
This means that the iterator should always be fully exhausted!
 
 
 
If you want to keep handles e.g. because you need to store all of them and
 
use them later, set `close_handles` to False and close them manually."""
 
 
 
def callback(hmonitor, hdc, lprect, lparam):
 
monitors.append(HMONITOR(hmonitor))
 
return True
 
 
 
monitors = []
 
if not windll.user32.EnumDisplayMonitors(None, None, _MONITORENUMPROC(callback), None):
 
raise WinError('EnumDisplayMonitors failed')
 
 
 
for monitor in monitors:
 
# Get physical monitor count
 
count = DWORD()
 
if not windll.dxva2.GetNumberOfPhysicalMonitorsFromHMONITOR(monitor, byref(count)):
 
raise WinError()
 
# Get physical monitor handles
 
physical_array = (_PHYSICAL_MONITOR * count.value)()
 
if not windll.dxva2.GetPhysicalMonitorsFromHMONITOR(monitor, count.value, physical_array):
 
raise WinError()
 
 
for physical in physical_array:
 
handle = physical.handle
 
 
 
# Get physical monitor capabilities. This may take a while...
 
length = DWORD()
 
if not windll.dxva2.GetCapabilitiesStringLength(HANDLE(handle), byref(length)):
 
raise WinError()
 
capabilities_string = (c_char * length.value)()
 
if not windll.dxva2.CapabilitiesRequestAndCapabilitiesReply(HANDLE(handle), capabilities_string, length):
 
raise WinError()
 
raw_capabilities = capabilities_string.value.decode('ascii')
 
capabilities = _parse_capabilities_string(raw_capabilities)
 
if capabilities:
 
# We only care about the model info for now.
 
yield [capabilities['model'], handle]
 
if close_handles:
 
if not windll.dxva2.DestroyPhysicalMonitor(handle):
 
raise WinError()
 
 
 
 
def _parse_capabilities_string(capabilities_string):
 
level = 0
 
capabilities = {}
 
open_p = {}
 
close_p = {0: 0}
 
id = {}
 
for i, chr in enumerate(capabilities_string):
 
if chr == '(':
 
if i == 0:
 
close_p[0] = 1
 
continue
 
open_p[level] = i
 
if level == 0:
 
id[0] = capabilities_string[close_p[0] + 1:i]
 
level += 1
 
elif chr == ')':
 
level -= 1
 
close_p[level] = i
 
if level == 0:
 
values = capabilities_string[open_p[0] + 1:i]
 
# We only care about the model info for now.
 
if id[0] == 'model':
 
capabilities[id[0]] = values
 
return capabilities
 
 
 
 
 
def set_vcp_feature(monitor, code, value):
 
"""Sends a DDC command to the specified monitor.
 
 
 
See this link for a list of commands:
 
ftp://ftp.cis.nctu.edu.tw/pub/csie/Software/X11/private/VeSaSpEcS/VESA_Document_Center_Monitor_Interface/mccsV3.pdf
 
"""
 
if not windll.dxva2.SetVCPFeature(HANDLE(monitor), BYTE(code), DWORD(value)):
 
raise WinError()
 
 
 
  
for model, handle in _iter_physical_monitors():
+
def main():
if model == "XL2420Z":
+
    """Lots of useless code here."""
set_vcp_feature(handle, 0xDC, 12) # picture mode
+
    if True:
+
        print "Hello, world!"
time.sleep(2) # wait for picture mode to load
+
        return None # Explicitly returning None!
+
    else:
set_vcp_feature(handle, 0x10, 31) # brightness
+
        raise Exception
set_vcp_feature(handle, 0x12, 50) # contrast
+
set_vcp_feature(handle, 0xF0, 0) # AMA (overdrive)
+
if __name__ == "__main__":
 +
    main()
 +
</syntaxhighlight><br/>
  
</syntaxhighlight>
+
<!-- Room for extra headers, like ==Course==, or ==Troubleshooting== -->
  
 
==See Also== <!-- Optional -->
 
==See Also== <!-- Optional -->
*[[Meta:Templates/Hardware]]
+
*[[Project:Samples/Hardware|Samples/Hardware]]
 +
*{{tl|Infobox_software}}
 +
*{{tl|Infobox_tsg}}
  
 +
==References== <!-- Optional, include only if <ref> tags are used in the article. -->
 +
<references />
  
<!-- Future content
+
==External Links== <!-- Optional -->
==Notes==
+
*{{Official website|https://about.gitlab.com/}}
{{reflist|group=note}}
+
*[http://tsgdoc.socsci.ru.nl tsgdoc]&nbsp;– Technical documentation.
-->
 
 
 
==References==
 
<references />
 

Latest revision as of 16:12, 7 March 2024

Software name
Placeholder.png
Development statusActive
Written inRuby
Operating systemMicrosoft Windows, Linux, MacOSX
LicenseCreative Commons Attribution-ShareAlike 4.0
Websitewww.gitlab.nl
Downloads
Manuals

Introduction. What does this software do? Who are the intended users?


Features

This software is made to do this, it has these unique selling points:

  • Feature 1
  • Feature 2
  • Feature 3

Requirements

  • Microsoft Windows XP or later.
  • Intel Core 2 Duo E8600 or higher.
  • Python

Installation

Windows 7 64-bit

  1. Step 1
  2. Step 2
  3. Step 3

Configuration

General settings. For CMD commands, you can use this format:
ping 127.0.0.1 -n 50 -l 1024

License

License setup.

Usage

Templates and how-to's go here.

Python

 1#In the syntaxhighlight tag, change lang value to desired language. 
 2#For the list of supported languages, see http://www.mediawiki.org/wiki/Extension:SyntaxHighlight_GeSHi#Supported_languages
 3
 4def main():
 5    """Lots of useless code here."""
 6    if True:
 7        print "Hello, world!"
 8        return None # Explicitly returning None!
 9    else:
10        raise Exception
11 
12if __name__ == "__main__":
13    main()



See Also

References


External Links