identifier
stringlengths 42
383
| collection
stringclasses 1
value | open_type
stringclasses 1
value | license
stringlengths 0
1.81k
| date
float64 1.99k
2.02k
⌀ | title
stringlengths 0
100
| creator
stringlengths 1
39
| language
stringclasses 157
values | language_type
stringclasses 2
values | word_count
int64 1
20k
| token_count
int64 4
1.32M
| text
stringlengths 5
1.53M
| __index_level_0__
int64 0
57.5k
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|
https://github.com/tiy-curtissimo/tiy-slate-201703/blob/master/day-2/class-code/node_modules/nymag-handlebars/node_modules/comma-it/comma-it.js
|
Github Open Source
|
Open Source
|
MIT
| 2,017
|
tiy-slate-201703
|
tiy-curtissimo
|
JavaScript
|
Code
| 152
| 384
|
// Simplest possible solution to turn numbers into nicely seperated amounts:
// 1234 => 1 234
// When precision option defined number of precision to keep, defaults to 2
module.exports = function commaIt(num, options) {
//Conversion to string and default return managment
number = num.toString();
if(number.length === 0) return '0' + decimalSeperator + '00';
var negativeSign = '';
if (number.indexOf('-') === 0) {
number = number.replace('-', '');
negativeSign = '-';
}
//Set up default seperators
precision = (options && typeof options['precision'] !== 'undefined' ) ? parseInt(options['precision'], 10) : 2;
thousandSeperator = (options && options['thousandSeperator']) || ' ';
decimalSeperator = (options && options['decimalSeperator']) || ',';
var replacmentRegex = '$1' + thousandSeperator;
//Actual parsing of two side of the number
var amount = number.split(decimalSeperator)[0];
var floats = (precision > 0) ? (decimalSeperator + ((number.split(decimalSeperator)[1] || '') + '00').substr(0, precision)) : '' ;
var numberified = amount.split('').reverse().join('').replace(/(\d{3}(?!$))/g, replacmentRegex).split('').reverse().join('');
return negativeSign + numberified + floats;
};
| 7,292
|
https://github.com/gakkifan2020/YoloV3_From_calmisential_workspace/blob/master/write_coco_to_txt.py
|
Github Open Source
|
Open Source
|
MIT
| 2,022
|
YoloV3_From_calmisential_workspace
|
gakkifan2020
|
Python
|
Code
| 16
| 68
|
from data_process.parse_coco import ParseCOCO
from configuration import TXT_DIR
if __name__ == '__main__':
coco = ParseCOCO()
coco.write_data_to_txt(txt_dir=TXT_DIR)
| 4,726
|
https://github.com/zarmian/retro-updates/blob/master/app/Http/Models/Employees/EmployeesRoles.php
|
Github Open Source
|
Open Source
|
MIT
| null |
retro-updates
|
zarmian
|
PHP
|
Code
| 20
| 73
|
<?php
namespace App\Http\Models\Employees;
use Illuminate\Database\Eloquent\Model;
class EmployeesRoles extends Model
{
/**
* Declaring table
*/
public $table = "tbl_employees_roles";
}
| 60
|
https://github.com/bingo-soft/jabe/blob/master/src/Impl/Pvm/Runtime/PvmExecutionImpl.php
|
Github Open Source
|
Open Source
|
MIT
| 2,023
|
jabe
|
bingo-soft
|
PHP
|
Code
| 7,589
| 21,375
|
<?php
namespace Jabe\Impl\Pvm\Runtime;
use Jabe\ProcessEngineException;
use Jabe\Impl\ProcessEngineLogger;
use Jabe\Impl\Bpmn\Helper\BpmnProperties;
use Jabe\Impl\Context\Context;
use Jabe\Impl\Core\Instance\CoreExecution;
use Jabe\Impl\Core\Variable\Event\VariableEvent;
use Jabe\Impl\Core\Variable\Scope\AbstractVariableScope;
use Jabe\Impl\Form\FormPropertyHelper;
use Jabe\Impl\History\Event\{
HistoryEvent,
HistoryEventProcessor,
HistoryEventCreator,
HistoryEventTypes
};
use Jabe\Impl\History\Producer\HistoryEventProducerInterface;
use Jabe\Impl\Incident\{
IncidentContext,
IncidentHandlerInterface,
IncidentHandling
};
use Jabe\Impl\Persistence\Entity\{
DelayedVariableEvent,
IncidentEntity
};
use Jabe\Impl\Pvm\{
PvmActivityInterface,
PvmException,
PvmExecutionInterface,
PvmLogger,
PvmProcessDefinitionInterface,
PvmProcessInstanceInterface,
PvmScopeInterface,
PvmTransitionInterface
};
use Jabe\Impl\Pvm\Delegate\{
ActivityExecutionInterface,
CompositeActivityBehaviorInterface,
ModificationObserverBehaviorInterface,
SignallableActivityBehaviorInterface
};
use Jabe\Impl\Pvm\Process\{
ActivityImpl,
ActivityStartBehavior,
ProcessDefinitionImpl,
ScopeImpl,
TransitionImpl
};
use Jabe\Impl\Pvm\Runtime\Operation\{
PvmAtomicOperationInterface,
AbstractPvmEventAtomicOperation
};
use Jabe\Impl\Tree\{
ExecutionWalker,
FlowScopeWalker,
LeafActivityInstanceExecutionCollector,
ReferenceWalker,
ScopeCollector,
ScopeExecutionCollector,
TreeVisitorInterface,
WalkConditionInterface
};
use Jabe\Impl\Util\EnsureUtil;
use Jabe\Runtime\IncidentInterface;
use Jabe\Variable\VariableMapInterface;
abstract class PvmExecutionImpl extends CoreExecution implements ActivityExecutionInterface, PvmProcessInstanceInterface
{
//private static final PvmLogger LOG = ProcessEngineLogger.PVM_LOGGER;
protected $processDefinition;
protected $scopeInstantiationContext;
protected bool $ignoreAsync = false;
/**
* true for process instances in the initial phase. Currently
* this controls that historic variable updates created during this phase receive
* the <code>initial</code> flag (see HistoricVariableUpdateEventEntity#isInitial).
*/
protected bool $isStarting = false;
// current position /////////////////////////////////////////////////////////
/**
* current activity
*/
protected $activity;
/**
* the activity which is to be started next
*/
protected $nextActivity;
/**
* the transition that is currently being taken
*/
protected $transition;
/**
* A list of outgoing transitions from the current activity
* that are going to be taken
*/
protected $transitionsToTake = null;
/**
* the unique id of the current activity instance
*/
protected $activityInstanceId;
/**
* the id of a case associated with this execution
*/
//protected $caseInstanceId;
protected $replacedBy;
// cascade deletion ////////////////////////////////////////////////////////
protected bool $deleteRoot = false;
protected $deleteReason;
protected bool $externallyTerminated = false;
//state/type of execution //////////////////////////////////////////////////
/**
* indicates if this execution represents an active path of execution.
* Executions are made inactive in the following situations:
* <ul>
* <li>an execution enters a nested scope</li>
* <li>an execution is split up into multiple concurrent executions, then the parent is made inactive.</li>
* <li>an execution has arrived in a parallel gateway or join and that join has not yet activated/fired.</li>
* <li>an execution is ended.</li>
* </ul>
*/
protected bool $isActive = true;
protected bool $isScope = true;
protected bool $isConcurrent = false;
protected bool $isEnded = false;
protected bool $isEventScope = false;
protected bool $isRemoved = false;
/**
* transient; used for process instance modification to preserve a scope from getting deleted
*/
protected bool $preserveScope = false;
/**
* marks the current activity instance
*/
protected $activityInstanceState;
protected bool $activityInstanceEndListenersFailed = false;
// sequence counter ////////////////////////////////////////////////////////
protected int $sequenceCounter = 0;
public function __construct()
{
$this->activityInstanceState = ActivityInstanceState::default()->getStateCode();
}
// API ////////////////////////////////////////////////
/**
* creates a new execution. properties processDefinition, processInstance and activity will be initialized.
*/
abstract public function createExecution(?bool $initializeExecutionStartContext = null): PvmExecutionImpl;
public function createSubProcessInstance(PvmProcessDefinitionInterface $processDefinition, ?string $businessKey = null, ?string $caseInstanceId = null): PvmExecutionImpl
{
$subProcessInstance = $this->newExecution();
// manage bidirectional super-subprocess relation
$subProcessInstance->setSuperExecution($this);
$this->setSubProcessInstance($subProcessInstance);
// Initialize the new execution
$subProcessInstance->setProcessDefinition($processDefinition);
$subProcessInstance->setProcessInstance($subProcessInstance);
$subProcessInstance->setActivity($processDefinition->getInitial());
if ($businessKey !== null) {
$subProcessInstance->setBusinessKey($businessKey);
}
/*if (caseInstanceId !== null) {
subProcessInstance->setCaseInstanceId(caseInstanceId);
}*/
return $subProcessInstance;
}
abstract protected function newExecution(): PvmExecutionImpl;
// sub case instance
/*abstract public function CmmnExecution createSubCaseInstance(CmmnCaseDefinition caseDefinition);
@Override
abstract public function CmmnExecution createSubCaseInstance(CmmnCaseDefinition caseDefinition, String businessKey);*/
abstract public function initialize(): void;
abstract public function initializeTimerDeclarations(): void;
public function executeIoMapping(): void
{
// execute Input Mappings (if they exist).
$currentScope = $this->getScopeActivity();
if ($currentScope != $currentScope->getProcessDefinition()) {
$currentActivity = $currentScope;
if ($currentActivity !== null && $currentActivity->getIoMapping() !== null && !$this->skipIoMapping) {
$currentActivity->getIoMapping()->executeInputParameters($this);
}
}
}
public function startWithFormProperties(VariableMapInterface $formProperties): void
{
$this->start(null, $formProperties);
}
public function start(?VariableMapInterface $variables = null, ?VariableMapInterface $formProperties = null, ...$args): void
{
$this->initialize();
$this->fireHistoricProcessStartEvent();
if (!empty($variables)) {
$this->setVariables($variables);
}
if ($formProperties !== null) {
FormPropertyHelper::initFormPropertiesOnScope($formProperties, $this);
}
$this->initializeTimerDeclarations();
$this->performOperation(AtomicOperation::processStart(), ...$args);
}
/**
* perform starting behavior but don't execute the initial activity
*
* @param variables the variables which are used for the start
*/
public function startWithoutExecuting(?VariableMapInterface $variables = null): void
{
$this->initialize();
$this->fireHistoricProcessStartEvent();
$this->setActivityInstanceId($this->getId());
$this->setVariables($variables);
$this->initializeTimerDeclarations();
$this->performOperation(AtomicOperation::fireProcessStart());
$this->setActivity(null);
}
abstract public function fireHistoricProcessStartEvent(): void;
public function destroy(): void
{
//LOG.destroying(this);
$this->setScope(false);
}
public function removeAllTasks(): void
{
}
protected function removeEventScopes(): void
{
$childExecutions = $this->getEventScopeExecutions();
foreach ($childExecutions as $childExecution) {
//LOG.removingEventScope(childExecution);
$childExecution->destroy();
$childExecution->remove();
}
}
public function clearScope(?string $reason, bool $skipCustomListeners, bool $skipIoMappings, bool $externallyTerminated): void
{
$this->skipCustomListeners = $skipCustomListeners;
$this->skipIoMapping = $skipIoMappings;
if ($this->getSubProcessInstance() !== null) {
$this->getSubProcessInstance()->deleteCascade($reason, $skipCustomListeners, $skipIoMappings, $externallyTerminated, false);
}
// remove all child executions and sub process instances:
$executions = $this->getNonEventScopeExecutions();
foreach ($executions as $childExecution) {
if ($childExecution->getSubProcessInstance() !== null) {
$childExecution->getSubProcessInstance()->deleteCascade($reason, $skipCustomListeners, $skipIoMappings, $externallyTerminated, false);
}
$childExecution->deleteCascade($reason, $skipCustomListeners, $skipIoMappings, $externallyTerminated, false);
}
// fire activity end on active activity
$activity = $this->getActivity();
if ($this->isActive && $activity !== null) {
// set activity instance state to cancel
if ($this->activityInstanceState != ActivityInstanceState::ending()->getStateCode()) {
$this->setCanceled(true);
$this->performOperation(AtomicOperation::fireActivityEnd());
}
// set activity instance state back to 'default'
// -> execution will be reused for executing more activities and we want the state to
// be default initially.
$this->activityInstanceState = ActivityInstanceState::default()->getStateCode();
}
}
/**
* Interrupts an execution
*/
public function interrupt(?string $reason, ?bool $skipCustomListeners = false, ?bool $skipIoMappings = false, ?bool $externallyTerminated = false): void
{
//LOG.interruptingExecution(reason, skipCustomListeners);
$this->clearScope($reason, $skipCustomListeners, $skipIoMappings, $externallyTerminated);
}
/**
* Ends an execution. Invokes end listeners for the current activity and notifies the flow scope execution
* of this happening which may result in the flow scope ending.
*
* @param completeScope true if ending the execution contributes to completing the BPMN 2.0 scope
*/
public function end(bool $completeScope): void
{
$this->setCompleteScope($completeScope);
$this->isActive = false;
$this->isEnded = true;
if ($this->hasReplacedParent()) {
$this->getParent()->replacedBy = null;
}
$this->performOperation(AtomicOperation::activityNotifyListenerEnd());
}
public function endCompensation(): void
{
$this->performOperation(AtomicOperation::fireActivityEnd());
$this->remove();
$parent = $this->getParent();
if ($parent->getActivity() === null) {
$parent->setActivity($this->getActivity()->getFlowScope());
}
$parent->signal("compensationDone", null);
}
/**
* <p>Precondition: execution is already ended but this has not been propagated yet.</p>
* <p>
* <p>Propagates the ending of this execution to the flowscope execution; currently only supports
* the process instance execution</p>
*/
public function propagateEnd(): void
{
if (!$this->isEnded()) {
throw new ProcessEngineException($this->__toString() . " must have ended before ending can be propagated");
}
if ($this->isProcessInstanceExecution()) {
$this->performOperation(AtomicOperation::processEnd());
} else {
// not supported yet
}
}
public function remove(): void
{
$parent = $this->getParent();
if ($parent !== null) {
$executions = &$parent->getExecutions();
foreach ($executions as $key => $ex) {
if ($ex == $this) {
unset($executions[$key]);
}
}
// if the sequence counter is greater than the
// sequence counter of the parent, then set
// the greater sequence counter on the parent.
$parentSequenceCounter = $parent->getSequenceCounter();
$mySequenceCounter = $this->getSequenceCounter();
if ($mySequenceCounter > $parentSequenceCounter) {
$parent->setSequenceCounter($mySequenceCounter);
}
// propagate skipping configuration upwards, if it was not initially set on
// the root execution
$parent->skipCustomListeners |= $this->skipCustomListeners;
$parent->skipIoMapping |= $this->skipIoMapping;
}
$this->isActive = false;
$this->isEnded = true;
$this->isRemoved = true;
if ($this->hasReplacedParent()) {
$this->getParent()->replacedBy = null;
}
$this->removeEventScopes();
}
//abstract protected function removeExecution(PvmExecutionImpl $execution): void;
//abstract protected function addExecution(PvmExecutionImpl $execution): void;
public function isRemoved(): bool
{
return $this->isRemoved;
}
public function createConcurrentExecution(): PvmExecutionImpl
{
if (!$this->isScope()) {
throw new ProcessEngineException("Cannot create concurrent execution for " . $this);
}
// The following covers the three cases in which a concurrent execution may be created
// (this execution is the root in each scenario).
//
// Note: this should only consider non-event-scope executions. Event-scope executions
// are not relevant for the tree structure and should remain under their original parent.
//
//
// (1) A compacted tree:
//
// Before: After:
// ------- -------
// | e1 | | e1 |
// ------- -------
// / \
// ------- -------
// | e2 | | e3 |
// ------- -------
//
// e2 replaces e1; e3 is the new root for the activity stack to instantiate
//
//
// (2) A single child that is a scope execution
// Before: After:
// ------- -------
// | e1 | | e1 |
// ------- -------
// | / \
// ------- ------- -------
// | e2 | | e3 | | e4 |
// ------- ------- -------
// |
// -------
// | e2 |
// -------
//
//
// e3 is created and is concurrent;
// e4 is the new root for the activity stack to instantiate
//
// (3) Existing concurrent execution(s)
// Before: After:
// ------- ---------
// | e1 | | e1 |
// ------- ---------
// / \ / | \
// ------- ------- ------- ------- -------
// | e2 | .. | eX | | e2 |..| eX | | eX+1|
// ------- ------- ------- ------- -------
//
// eX+1 is concurrent and the new root for the activity stack to instantiate
$children = $this->getNonEventScopeExecutions();
// whenever we change the set of child executions we have to force an update
// on the scope executions to avoid concurrent modifications (e.g. tree compaction)
// that go unnoticed
$this->forceUpdate();
if (empty($children)) {
// (1)
$replacingExecution = $this->createExecution();
$replacingExecution->setConcurrent(true);
$replacingExecution->setScope(false);
$replacingExecution->replace($this);
$this->inactivate();
$this->setActivity(null);
} elseif (count($children) == 1) {
// (2)
$child = $children[0];
$concurrentReplacingExecution = $this->createExecution();
$concurrentReplacingExecution->setConcurrent(true);
$concurrentReplacingExecution->setScope(false);
$concurrentReplacingExecution->setActive(false);
$concurrentReplacingExecution->onConcurrentExpand($this);
$child->setParent($concurrentReplacingExecution);
$this->leaveActivityInstance();
$this->setActivity(null);
}
// (1), (2), and (3)
$concurrentExecution = $this->createExecution();
$concurrentExecution->setConcurrent(true);
$concurrentExecution->setScope(false);
return $concurrentExecution;
}
public function tryPruneLastConcurrentChild(): bool
{
if (count($this->getNonEventScopeExecutions()) == 1) {
$lastConcurrent = $this->getNonEventScopeExecutions()[0];
if ($lastConcurrent->isConcurrent()) {
if (!$lastConcurrent->isScope()) {
$this->setActivity($lastConcurrent->getActivity());
$this->setTransition($lastConcurrent->getTransition());
$this->replace($lastConcurrent);
// Move children of lastConcurrent one level up
if ($lastConcurrent->hasChildren()) {
foreach ($lastConcurrent->getExecutionsAsCopy() as $childExecution) {
$childExecution->setParent($this);
}
}
// Make sure parent execution is re-activated when the last concurrent
// child execution is active
if (!$this->isActive() && $lastConcurrent->isActive()) {
$this->setActive(true);
}
$lastConcurrent->remove();
} else {
// legacy behavior
LegacyBehavior::pruneConcurrentScope($lastConcurrent);
}
return true;
}
}
return false;
}
public function deleteCascade(
?string $deleteReason,
?bool $skipCustomListeners = false,
?bool $skipIoMappings = false,
?bool $externallyTerminated = false,
?bool $skipSubprocesses = false
): void {
$this->deleteReason = $deleteReason;
$this->setDeleteRoot(true);
$this->isEnded = true;
$this->skipCustomListeners = $skipCustomListeners;
$this->skipIoMapping = $skipIoMappings;
$this->externallyTerminated = $externallyTerminated;
$this->skipSubprocesses = $skipSubprocesses;
$this->performOperation(AtomicOperation::deleteCascade());
}
public function executeEventHandlerActivity(ActivityImpl $eventHandlerActivity): void
{
// the target scope
$flowScope = $eventHandlerActivity->getFlowScope();
// the event scope (the current activity)
$eventScope = $eventHandlerActivity->getEventScope();
if (
$eventHandlerActivity->getActivityStartBehavior() == ActivityStartBehavior::CONCURRENT_IN_FLOW_SCOPE
&& $flowScope != $eventScope
) {
// the current scope is the event scope of the activity
$this->findExecutionForScope($eventScope, $flowScope)->executeActivity($eventHandlerActivity);
} else {
$this->executeActivity($eventHandlerActivity);
}
}
// tree compaction & expansion ///////////////////////////////////////////
/**
* <p>Returns an execution that has replaced this execution for executing activities in their shared scope.</p>
* <p>Invariant: this execution and getReplacedBy() execute in the same scope.</p>
*/
abstract public function getReplacedBy(): ?PvmExecutionImpl;
/**
* Instead of {@link #getReplacedBy()}, which returns the execution that this execution was directly replaced with,
* this resolves the chain of replacements (i.e. in the case the replacedBy execution itself was replaced again)
*/
public function resolveReplacedBy(): ?PvmExecutionImpl
{
// follow the links of execution replacement;
// note: this can be at most two hops:
// case 1:
// this execution is a scope execution
// => tree may have expanded meanwhile
// => scope execution references replacing execution directly (one hop)
//
// case 2:
// this execution is a concurrent execution
// => tree may have compacted meanwhile
// => concurrent execution references scope execution directly (one hop)
//
// case 3:
// this execution is a concurrent execution
// => tree may have compacted/expanded/compacted/../expanded any number of times
// => the concurrent execution has been removed and therefore references the scope execution (first hop)
// => the scope execution may have been replaced itself again with another concurrent execution (second hop)
// note that the scope execution may have a long "history" of replacements, but only the last replacement is relevant here
$replacingExecution = $this->getReplacedBy();
if ($replacingExecution !== null) {
$secondHopReplacingExecution = $replacingExecution->getReplacedBy();
if ($secondHopReplacingExecution !== null) {
$replacingExecution = $secondHopReplacingExecution;
}
}
return $replacingExecution;
}
public function hasReplacedParent(): bool
{
return $this->getParent() !== null && $this->getParent()->getReplacedBy() == $this;
}
public function isReplacedByParent(): bool
{
return $this->getReplacedBy() !== null && $this->getReplacedBy() == $this->getParent();
}
/**
* <p>Replace an execution by this execution. The replaced execution has a pointer ({@link #getReplacedBy()}) to this execution.
* This pointer is maintained until the replaced execution is removed or this execution is removed/ended.</p>
* <p>
* <p>This is used for two cases: Execution tree expansion and execution tree compaction</p>
* <ul>
* <li><b>expansion</b>: Before:
* <pre>
* -------
* | e1 | scope
* -------
* </pre>
* After:
* <pre>
* -------
* | e1 | scope
* -------
* |
* -------
* | e2 | cc (no scope)
* -------
* </pre>
* e2 replaces e1: it should receive all entities associated with the activity currently executed
* by e1; these are tasks, (local) variables, jobs (specific for the activity, not the scope)
* </li>
* <li><b>compaction</b>: Before:
* <pre>
* -------
* | e1 | scope
* -------
* |
* -------
* | e2 | cc (no scope)
* -------
* </pre>
* After:
* <pre>
* -------
* | e1 | scope
* -------
* </pre>
* e1 replaces e2: it should receive all entities associated with the activity currently executed
* by e2; these are tasks, (all) variables, all jobs
* </li>
* </ul>
*
* @see #createConcurrentExecution()
* @see #tryPruneLastConcurrentChild()
*/
public function replace(PvmExecutionImpl $execution): void
{
// activity instance id handling
$this->activityInstanceId = $execution->getActivityInstanceId();
$this->isActive = $execution->isActive;
$this->replacedBy = null;
$execution->replacedBy = $this;
$this->transitionsToTake = $execution->transitionsToTake;
$execution->leaveActivityInstance();
}
/**
* Callback on tree expansion when this execution is used as the concurrent execution
* where the argument's children become a subordinate to. Note that this case is not the inverse
* of replace because replace has the semantics that the replacing execution can be used to continue
* execution of this execution's activity instance.
*/
public function onConcurrentExpand(PvmExecutionImpl $scopeExecution): void
{
// by default, do nothing
}
// methods that translate to operations /////////////////////////////////////
public function signal(?string $signalName, $signalData): void
{
if ($this->getActivity() === null) {
throw new PvmException("cannot signal execution " . $this->id . ": it has no current activity");
}
$activityBehavior = $this->activity->getActivityBehavior();
try {
$activityBehavior->signal($this, $signalName, $signalData);
} catch (\Throwable $e) {
throw new PvmException("couldn't process signal '" . $signalName . "' on activity '" . $this->activity->getId() . "': " . $e->getMessage(), $e);
}
}
public function take(): void
{
if ($this->transition === null) {
throw new PvmException($this->__toString() . ": no transition to take specified");
}
$transitionImpl = $this->transition;
$this->setActivity($transitionImpl->getSource());
// while executing the transition, the activityInstance is 'null'
// (we are not executing an activity)
$this->setActivityInstanceId(null);
$this->setActive(true);
$this->performOperation(AtomicOperation::transitionNotifyListenerTake());
}
/**
* Execute an activity which is not contained in normal flow (having no incoming sequence flows).
* Cannot be called for activities contained in normal flow.
* <p>
* First, the ActivityStartBehavior is evaluated.
* In case the start behavior is not ActivityStartBehavior#DEFAULT, the corresponding start
* behavior is executed before executing the activity.
* <p>
* For a given activity, the execution on which this method must be called depends on the type of the start behavior:
* <ul>
* <li>CONCURRENT_IN_FLOW_SCOPE: scope execution for PvmActivity#getFlowScope()</li>
* <li>INTERRUPT_EVENT_SCOPE: scope execution for PvmActivity#getEventScope()</li>
* <li>CANCEL_EVENT_SCOPE: scope execution for PvmActivity#getEventScope()</li>
* </ul>
*
* @param activity the activity to start
*/
public function executeActivity(PvmActivityInterface $activity): void
{
if (!empty($activity->getIncomingTransitions())) {
throw new ProcessEngineException("Activity is contained in normal flow and cannot be executed using executeActivity().");
}
$activityStartBehavior = $activity->getActivityStartBehavior();
if (!$this->isScope() && ActivityStartBehavior::DEFAULT != $activityStartBehavior) {
throw new ProcessEngineException("Activity '" . $activity . "' with start behavior '" . $activityStartBehavior . "'"
. "cannot be executed by non-scope execution.");
}
$activityImpl = $activity;
$this->isEnded = false;
$this->isActive = true;
switch ($activityStartBehavior) {
case ActivityStartBehavior::CONCURRENT_IN_FLOW_SCOPE:
$this->nextActivity = $activityImpl;
$this->performOperation(AtomicOperation::activityStartConcurrent());
break;
case ActivityStartBehavior::CANCEL_EVENT_SCOPE:
$this->nextActivity = $activityImpl;
$this->performOperation(AtomicOperation::activityStartCancelScope());
break;
case ActivityStartBehavior::INTERRUPT_EVENT_SCOPE:
$this->nextActivity = $activityImpl;
$this->performOperation(AtomicOperation::activityStartInterruptScope());
break;
default:
$this->setActivity($activityImpl);
$this->setActivityInstanceId(null);
$this->performOperation(AtomicOperation::activityStartCreateScope());
break;
}
}
/**
* Instantiates the given activity stack under this execution.
* Sets the variables for the execution responsible to execute the most deeply nested
* activity.
*
* @param activityStack The most deeply nested activity is the last element in the list
*/
public function executeActivitiesConcurrent(
array &$activityStack,
?PvmActivityInterface $targetActivity = null,
?PvmTransitionInterface $targetTransition = null,
?array $variables = [],
?array $localVariables = [],
?bool $skipCustomListeners = false,
?bool $skipIoMappings = false
): void {
$flowScope = null;
if (!empty($activityStack)) {
$flowScope = $activityStack[0]->getFlowScope();
} elseif ($targetActivity !== null) {
$flowScope = $targetActivity->getFlowScope();
} elseif ($targetTransition !== null) {
$flowScope = $targetTransition->getSource()->getFlowScope();
}
$propagatingExecution = null;
if ($flowScope->getActivityBehavior() instanceof ModificationObserverBehaviorInterface) {
$flowScopeBehavior = $flowScope->getActivityBehavior();
$propagatingExecution = $flowScopeBehavior->createInnerInstance($this);
} else {
$propagatingExecution = $this->createConcurrentExecution();
}
$propagatingExecution->executeActivities(
$activityStack,
$targetActivity,
$targetTransition,
$variables,
$localVariables,
$skipCustomListeners,
$skipIoMappings
);
}
/**
* Instantiates the given set of activities and returns the execution for the bottom-most activity
*/
public function instantiateScopes(array &$activityStack, bool $skipCustomListeners, bool $skipIoMappings): array
{
if (empty($activityStack)) {
return [];
}
$this->skipCustomListeners = $skipCustomListeners;
$this->skipIoMapping = $skipIoMappings;
$executionStartContext = new ScopeInstantiationContext();
$instantiationStack = new InstantiationStack($activityStack);
$executionStartContext->setInstantiationStack($instantiationStack);
$this->setStartContext($executionStartContext);
$this->performOperation(AtomicOperation::activityInitStackAndReturn());
$createdExecutions = [];
$currentExecution = $this;
foreach ($activityStack as $instantiatedActivity) {
// there must exactly one child execution
$currentExecution = $currentExecution->getNonEventScopeExecutions()[0];
if ($currentExecution->isConcurrent()) {
// there may be a non-scope execution that we have to skip (e.g. multi-instance)
$currentExecution = $currentExecution->getNonEventScopeExecutions()[0];
}
$createdExecutions[] = [$instantiatedActivity, $currentExecution];
}
return $createdExecutions;
}
/**
* Instantiates the given activity stack. Uses this execution to execute the
* highest activity in the stack.
* Sets the variables for the execution responsible to execute the most deeply nested
* activity.
*
* @param activityStack The most deeply nested activity is the last element in the list
*/
public function executeActivities(
array &$activityStack,
?PvmActivityInterface $targetActivity = null,
?PvmTransitionInterface $targetTransition = null,
?array $variables = [],
?array $localVariables = [],
?bool $skipCustomListeners = false,
?bool $skipIoMappings = false
): void {
$this->skipCustomListeners = $skipCustomListeners;
$this->skipIoMapping = $skipIoMappings;
$this->activityInstanceId = null;
$this->isEnded = false;
if (!empty($activityStack)) {
$executionStartContext = new ScopeInstantiationContext();
$instantiationStack = new InstantiationStack($activityStack, $targetActivity, $targetTransition);
$executionStartContext->setInstantiationStack($instantiationStack);
$executionStartContext->setVariables($variables);
$executionStartContext->setVariablesLocal($localVariables);
$this->setStartContext($executionStartContext);
$this->performOperation(AtomicOperation::activityInitStack());
} elseif ($targetActivity !== null) {
$this->setVariables($variables);
$this->setVariablesLocal($localVariables);
$this->setActivity($targetActivity);
$this->performOperation(AtomicOperation::activityStartCreateScope());
} elseif ($targetTransition !== null) {
$this->setVariables($variables);
$this->setVariablesLocal($localVariables);
$this->setActivity($targetTransition->getSource());
$this->setTransition($targetTransition);
$this->performOperation(AtomicOperation::trasitionStartNotifyListenerTake());
}
}
public function findInactiveConcurrentExecutions(PvmActivityInterface $activity): array
{
$inactiveConcurrentExecutionsInActivity = [];
if ($this->isConcurrent()) {
return $this->getParent()->findInactiveChildExecutions($activity);
} elseif (!$this->isActive()) {
$inactiveConcurrentExecutionsInActivity[] = $this;
}
return $inactiveConcurrentExecutionsInActivity;
}
public function findInactiveChildExecutions(PvmActivityInterface $activity): array
{
$inactiveConcurrentExecutionsInActivity = [];
$concurrentExecutions = $this->getAllChildExecutions();
foreach ($concurrentExecutions as $concurrentExecution) {
if ($concurrentExecution->getActivity() == $activity && !$concurrentExecution->isActive()) {
$inactiveConcurrentExecutionsInActivity[] = $concurrentExecution;
}
}
return $inactiveConcurrentExecutionsInActivity;
}
protected function getAllChildExecutions(): array
{
$childExecutions = [];
foreach ($this->getExecutions() as $childExecution) {
$childExecutions[] = $childExecution;
$childExecutions = array_merge($childExecutions, $childExecution->getAllChildExecutions());
}
return $childExecutions;
}
public function leaveActivityViaTransition($outgoingTransition, ?array $recyclableExecutions = []): void
{
if ($outgoingTransition instanceof PvmTransitionInterface) {
$transitions = [ $outgoingTransition ];
} else {
$transitions = $outgoingTransition;
}
$this->leaveActivityViaTransitions($transitions, $recyclableExecutions);
}
public function leaveActivityViaTransitions(array $outgoingTransitions, ?array $recyclableExecutions = []): void
{
// if recyclable executions size is greater
// than 1, then the executions are joined and
// the activity is left with 'this' execution,
// if it is not not the last concurrent execution.
// therefore it is necessary to remove the local
// variables (event if it is the last concurrent
// execution).
if (count($recyclableExecutions) > 1) {
$this->removeVariablesLocalInternal();
}
// mark all recyclable executions as ended
// if the list of recyclable executions also
// contains 'this' execution, then 'this' execution
// is also marked as ended. (if 'this' execution is
// pruned, then the local variables are not copied
// to the parent execution)
// this is a workaround to not delete all recyclable
// executions and create a new execution which leaves
// the activity.
foreach ($recyclableExecutions as $execution) {
$execution->setEnded(true);
}
// remove 'this' from recyclable executions to
// leave the activity with 'this' execution
// (when 'this' execution is the last concurrent
// execution, then 'this' execution will be pruned,
// and the activity is left with the scope
// execution)
foreach ($recyclableExecutions as $key => $execution) {
if ($execution == $this) {
unset($recyclableExecutions[$key]);
}
}
// End all other executions synchronously.
// This ensures a proper execution tree in case
// the activity is marked as 'async-after'.
// Otherwise, ending the other executions as well
// as the next logical operation are executed
// asynchronously. The order of those operations can
// not be guaranteed anymore. This can lead to executions
// getting stuck in case they rely on ending the other
// executions first.
foreach ($recyclableExecutions as $execution) {
$execution->setIgnoreAsync(true);
$execution->end(empty($outgoingTransitions));
}
$propagatingExecution = $this;
if (($replacedBy = $this->getReplacedBy()) !== null) {
$propagatingExecution = $replacedBy;
}
$propagatingExecution->isActive = true;
$propagatingExecution->isEnded = false;
if (empty($outgoingTransitions)) {
$propagatingExecution->end(!$propagatingExecution->isConcurrent());
} else {
$propagatingExecution->setTransitionsToTake($outgoingTransitions);
$propagatingExecution->performOperation(AbstractPvmEventAtomicOperation::transitionNotifyListenerEnd());
}
}
abstract protected function removeVariablesLocalInternal(): void;
public function isActive(?string $activityId = null): bool
{
if ($activityId !== null) {
return $this->findExecution($activityId) !== null;
}
return $this->isActive;
}
public function inactivate(): void
{
$this->isActive = false;
}
// executions ///////////////////////////////////////////////////////////////
abstract public function &getExecutions(): array;
abstract public function getExecutionsAsCopy(): array;
public function getNonEventScopeExecutions(): array
{
$children = $this->getExecutions();
$result = [];
foreach ($children as $child) {
if (!$child->isEventScope()) {
$result[] = $child;
}
}
return $result;
}
public function getEventScopeExecutions(): array
{
$children = $this->getExecutions();
$result = [];
foreach ($children as $child) {
if ($child->isEventScope()) {
$result[] = $child;
}
}
return $result;
}
public function findExecution(?string $activityId): ?PvmExecutionImpl
{
if (
($this->getActivity() !== null)
&& ($this->getActivity()->getId() == $activityId)
) {
return $this;
}
foreach ($this->getExecutions() as $nestedExecution) {
$result = $nestedExecution->findExecution($activityId);
if ($result !== null) {
return $result;
}
}
return null;
}
public function findExecutions(?string $activityId): array
{
$matchingExecutions = [];
$this->collectExecutions($activityId, $matchingExecutions);
return $matchingExecutions;
}
protected function collectExecutions(?string $activityId, array &$executions): array
{
if (
($this->getActivity() !== null)
&& ($this->getActivity()->getId() == $activityId)
) {
$executions[] = $this;
}
foreach ($this->getExecutions() as $nestedExecution) {
$nestedExecution->collectExecutions($activityId, $executions);
}
}
public function findActiveActivityIds(): array
{
$activeActivityIds = [];
$this->collectActiveActivityIds($activeActivityIds);
return $activeActivityIds;
}
protected function collectActiveActivityIds(array &$activeActivityIds): void
{
$activity = $this->getActivity();
if ($this->isActive && $activity !== null) {
$activeActivityIds[] = $activity->getId();
}
foreach ($this->getExecutions() as $execution) {
$execution->collectActiveActivityIds($activeActivityIds);
}
}
// business key /////////////////////////////////////////
public function getProcessBusinessKey(): ?string
{
return $this->getProcessInstance()->getBusinessKey();
}
public function setProcessBusinessKey(?string $businessKey): void
{
$processInstance = $this->getProcessInstance();
$processInstance->setBusinessKey($businessKey);
$historyLevel = Context::getCommandContext()->getProcessEngineConfiguration()->getHistoryLevel();
if ($historyLevel->isHistoryEventProduced(HistoryEventTypes::processInstanceUpdate(), $processInstance)) {
HistoryEventProcessor::processHistoryEvents(new class ($processInstance) extends HistoryEventCreator {
private $processInstance;
public function __construct($processInstance)
{
$this->processInstance = $processInstance;
}
public function createHistoryEvent(HistoryEventProducerInterface $producer): HistoryEvent
{
return $producer->createProcessInstanceUpdateEvt($this->processInstance);
}
});
}
}
public function getBusinessKey(): ?string
{
if ($this->isProcessInstanceExecution()) {
return $this->businessKey;
}
return $this->getProcessBusinessKey();
}
// process definition ///////////////////////////////////////////////////////
public function setProcessDefinition(ProcessDefinitionImpl $processDefinition): void
{
$this->processDefinition = $processDefinition;
}
public function getProcessDefinition(): ProcessDefinitionImpl
{
return $this->processDefinition;
}
// process instance /////////////////////////////////////////////////////////
/**
* ensures initialization and returns the process instance.
*/
abstract public function getProcessInstance(): PvmExecutionImpl;
abstract public function setProcessInstance(PvmExecutionImpl $pvmExecutionImpl): void;
// case instance id /////////////////////////////////////////////////////////
/*public function getCaseInstanceId(): ?string
{
return $this->caseInstanceId;
}
public function setCaseInstanceId(?string $caseInstanceId): void
{
$this->caseInstanceId = $caseInstanceId;
}*/
// activity /////////////////////////////////////////////////////////////////
/**
* ensures initialization and returns the activity
*/
public function getActivity(): ?ActivityImpl
{
return $this->activity;
}
public function getActivityId(): ?string
{
$activity = $this->getActivity();
if ($activity !== null) {
return $activity->getId();
}
return null;
}
public function getCurrentActivityName(): ?string
{
$activity = $this->getActivity();
if ($activity !== null) {
return $activity->getName();
}
return null;
}
public function getCurrentActivityId(): ?string
{
return $this->getActivityId();
}
public function setActivity(?PvmActivityInterface $activity = null): void
{
$this->activity = $activity;
}
public function enterActivityInstance(...$args): void
{
$activity = $this->getActivity();
$this->activityInstanceId = $this->generateActivityInstanceId($activity->getId(), ...$args);
//LOG.debugEnterActivityInstance(this, getParentActivityInstanceId());
// <LEGACY>: in general, io mappings may only exist when the activity is scope
// however, for multi instance activities, the inner activity does not become a scope
// due to the presence of an io mapping. In that case, it is ok to execute the io mapping
// anyway because the multi-instance body already ensures variable isolation
$this->executeIoMapping();
if ($activity->isScope()) {
$this->initializeTimerDeclarations();
}
$this->activityInstanceEndListenersFailed = false;
}
public function activityInstanceStarting(): void
{
$this->activityInstanceState = ActivityInstanceState::starting()->getStateCode();
}
public function activityInstanceStarted(): void
{
$this->activityInstanceState = ActivityInstanceState::default()->getStateCode();
}
public function activityInstanceDone(): void
{
$this->activityInstanceState = ActivityInstanceState::ending()->getStateCode();
}
public function activityInstanceEndListenerFailure(): void
{
$this->activityInstanceEndListenersFailed = true;
}
abstract protected function generateActivityInstanceId(?string $activityId, ...$args): ?string;
public function leaveActivityInstance(): void
{
if ($this->activityInstanceId !== null) {
//LOG.debugLeavesActivityInstance(this, activityInstanceId);
}
$this->activityInstanceId = $this->getParentActivityInstanceId();
$this->activityInstanceState = ActivityInstanceState::default()->getStateCode();
$this->activityInstanceEndListenersFailed = false;
}
public function getParentActivityInstanceId(): ?string
{
if ($this->isProcessInstanceExecution()) {
return $this->getId();
} else {
return $this->getParent()->getActivityInstanceId();
}
}
public function setActivityInstanceId(?string $activityInstanceId): void
{
$this->activityInstanceId = $activityInstanceId;
}
// parent ///////////////////////////////////////////////////////////////////
/**
* ensures initialization and returns the parent
*/
abstract public function getParent(): ?PvmExecutionImpl;
public function getParentId(): ?string
{
$parent = $this->getParent();
if ($parent !== null) {
return $parent->getId();
}
return null;
}
public function hasChildren(): bool
{
return !empty($this->getExecutions());
}
/**
* Sets the execution's parent and updates the old and new parents' set of
* child executions
*/
public function setParent(PvmExecutionImpl $parent): void
{
$currentParent = $this->getParent();
$this->setParentExecution($parent);
if ($currentParent !== null) {
$executions = &$currentParent->getExecutions();
foreach ($executions as $key => $execution) {
if ($execution == $this) {
unset($executions[$key]);
}
}
}
if ($parent !== null) {
$executions = &$parent->getExecutions();
$executions[] = $this;
}
}
/**
* Use #setParent to also update the child execution sets
*/
abstract public function setParentExecution(PvmExecutionImpl $parent): void;
// super- and subprocess executions /////////////////////////////////////////
abstract public function getSuperExecution(): ?PvmExecutionImpl;
abstract public function setSuperExecution(PvmExecutionImpl $superExecution): void;
abstract public function getSubProcessInstance(): ?PvmExecutionImpl;
abstract public function setSubProcessInstance(?PvmExecutionImpl $subProcessInstance): void;
// super case execution /////////////////////////////////////////////////////
//abstract public function CmmnExecution getSuperCaseExecution();
//abstract public function void setSuperCaseExecution(CmmnExecution superCaseExecution);
// sub case execution ///////////////////////////////////////////////////////
//abstract public function CmmnExecution getSubCaseInstance();
//abstract public function void setSubCaseInstance(CmmnExecution subCaseInstance);
// scopes ///////////////////////////////////////////////////////////////////
protected function getScopeActivity(): ScopeImpl
{
$scope = null;
// this if condition is important during process instance startup
// where the activity of the process instance execution may not be aligned
// with the execution tree
if ($this->isProcessInstanceExecution()) {
$scope = $this->getProcessDefinition();
} else {
$scope = $this->getActivity();
}
return $scope;
}
public function isScope(): bool
{
return $this->isScope;
}
public function setScope(bool $isScope): void
{
$this->isScope = $isScope;
}
/**
* For a given target flow scope, this method returns the corresponding scope execution.
* <p>
* Precondition: the execution is active and executing an activity.
* Can be invoked for scope and non scope executions.
*
* @param targetFlowScope mixed - scope activity or process definition for which the scope execution should be found
* @return PvmExecutionImpl the scope execution for the provided targetFlowScope
*/
public function findExecutionForFlowScope($targetFlowScope): ?PvmExecutionImpl
{
if (is_string($targetFlowScope)) {
$targetScopeId = $targetFlowScope;
EnsureUtil::ensureNotNull("target scope id", "targetScopeId", "targetScopeId", $targetScopeId);
$currentActivity = $this->getActivity();
EnsureUtil::ensureNotNull("activity of current execution", "currentActivity", $currentActivity);
$walker = new FlowScopeWalker($currentActivity);
$targetFlowScope = $walker->walkUntil(new class ($targetScopeId) implements WalkConditionInterface {
private $targetScopeId;
public function __construct(?string $targetScopeId)
{
$this->targetScopeId = $targetScopeId;
}
public function isFulfilled($scope = null): bool
{
return $scope === null || $scope->getId() == $this->targetScopeId;
}
});
if ($targetFlowScope === null) {
//throw LOG.scopeNotFoundException(targetScopeId, this->getId());
}
return $this->findExecutionForFlowScope($targetFlowScope);
} elseif ($targetFlowScope instanceof PvmScopeInterface) {
// if this execution is not a scope execution, use the parent
$scopeExecution = $this->isScope() ? $this : $this->getParent();
$currentActivity = $this->getActivity();
EnsureUtil::ensureNotNull("activity of current execution", "currentActivity", $currentActivity);
// if this is a scope execution currently executing a non scope activity
$currentActivity = $currentActivity->isScope() ? $currentActivity : $currentActivity->getFlowScope();
return $scopeExecution->findExecutionForScope($currentActivity, $targetFlowScope);
}
return null;
}
public function findExecutionForScope(ScopeImpl $currentScope, ScopeImpl $targetScope): ?PvmExecutionImpl
{
if (!$targetScope->isScope()) {
throw new ProcessEngineException("Target scope must be a scope.");
}
$activityExecutionMapping = $this->createActivityExecutionMapping($currentScope);
$scopeExecution = null;
foreach ($activityExecutionMapping as $map) {
if ($map[0] == $targetScope) {
$scopeExecution = $map[1];
}
}
if ($scopeExecution === null) {
// the target scope is scope but no corresponding execution was found
// => legacy behavior
$scopeExecution = LegacyBehavior::getScopeExecution(targetScope, activityExecutionMapping);
}
return $scopeExecution;
}
protected function getFlowScopeExecution(): PvmExecutionImpl
{
if (!$this->isScope || CompensationBehavior::executesNonScopeCompensationHandler($this)) {
// LEGACY: a correct implementation should also skip a compensation-throwing parent scope execution
// (since compensation throwing activities are scopes), but this cannot be done for backwards compatibility
// where a compensation throwing activity was no scope (and we would wrongly skip an execution in that case)
return $this->getParent()->getFlowScopeExecution();
}
return $this;
}
protected function getFlowScope(): ScopeImpl
{
$activity = $this->getActivity();
if (
!$activity->isScope() || $this->activityInstanceId === null
|| ($activity->isScope() && !$this->isScope() && $activity->getActivityBehavior() instanceof CompositeActivityBehaviorInterface)
) {
// if
// - this is a scope execution currently executing a non scope activity
// - or it is not scope but the current activity is (e.g. can happen during activity end, when the actual
// scope execution has been removed and the concurrent parent has been set to the scope activity)
// - or it is asyncBefore/asyncAfter
return $activity->getFlowScope();
}
return $activity;
}
/**
* Creates an extended mapping based on this execution and the given existing mapping.
* Any entry <code>mapping</code> in mapping that corresponds to an ancestor scope of
* <code>currentScope</code> is reused.
*/
public function createActivityExecutionMapping(
?ScopeImpl $currentScope = null,
?array $mapping = null
): array {
if ($currentScope !== null && $mapping !== null) {
if (!$this->isScope()) {
throw new ProcessEngineException("Execution must be a scope execution");
}
if (!$currentScope->isScope()) {
throw new ProcessEngineException("Current scope must be a scope.");
}
// collect all ancestor scope executions unless one is encountered that is already in "mapping"
$scopeExecutionCollector = new ScopeExecutionCollector();
(new ExecutionWalker($this))
->addPreVisitor($scopeExecutionCollector)
->walkWhile(new class ($mapping) implements WalkConditionInterface {
private $mapping;
public function __construct(array $mapping)
{
$this->mapping = $mapping;
}
public function isFulfilled($element = null): bool
{
$contains = false;
foreach ($this->mapping as $map) {
if ($map[1] == $element) {
$contains = true;
break;
}
}
return $element === null || $contains;
}
});
$scopeExecutions = $scopeExecutionCollector->getScopeExecutions();
// collect all ancestor scopes unless one is encountered that is already in "mapping"
$scopeCollector = new ScopeCollector();
(new FlowScopeWalker($currentScope))
->addPreVisitor($scopeCollector)
->walkWhile(new class ($mapping) implements WalkConditionInterface {
private $mapping;
public function __construct(array $mapping)
{
$this->mapping = $mapping;
}
public function isFulfilled($element = null): bool
{
$contains = false;
foreach ($this->mapping as $map) {
if ($map[0] == $element) {
$contains = true;
break;
}
}
return $element === null || $contains;
}
});
$scopes = $scopeCollector->getScopes();
$outerScope = new \stdClass();
$outerScope->scopes = $scopes;
$outerScope->scopeExecutions = $scopeExecutions;
// add all ancestor scopes and scopeExecutions that are already in "mapping"
// and correspond to ancestors of the topmost previously collected scope
$topMostScope = $scopes[count($scopes) - 1];
(new FlowScopeWalker($topMostScope->getFlowScope()))
->addPreVisitor(new class ($outerScope, $mapping) implements TreeVisitorInterface {
private $outerScope;
private $mapping;
public function __construct($outerScope, $mapping)
{
$this->outerScope = $outerScope;
$this->mapping = $mapping;
}
public function visit($obj): void
{
$this->outerScope->scopes[] = $obj;
$priorMappingExecution = null;
foreach ($this->mapping as $map) {
if ($map[0] == $obj) {
$priorMappingExecution = $map[1];
}
}
$contains = false;
foreach ($this->outerScope->scopeExecutions as $exec) {
if ($exec == $priorMappingExecution) {
$contains = true;
break;
}
}
if ($priorMappingExecution !== null && !$contains) {
$this->outerScope->scopeExecutions[] = $priorMappingExecution;
}
}
})
->walkWhile();
$scopes = $outerScope->scopes;
$scopeExecutions = $outerScope->scopeExecutions;
if (count($scopes) == count($scopeExecutions)) {
// the trees are in sync
$result = [];
for ($i = 0; $i < count($scopes); $i += 1) {
$result[] = [$scopes[$i], $scopeExecutions[$i]];
}
return $result;
} else {
// Wounderful! The trees are out of sync. This is due to legacy behavior
return LegacyBehavior::createActivityExecutionMapping($scopeExecutions, $scopes);
}
} elseif ($currentScope !== null) {
if (!$this->isScope()) {
throw new ProcessEngineException("Execution must be a scope execution");
}
if (!$currentScope->isScope()) {
throw new ProcessEngineException("Current scope must be a scope.");
}
// A single path in the execution tree from a leaf (no child executions) to the root
// may in fact contain multiple executions that correspond to leaves in the activity instance hierarchy.
//
// This is because compensation throwing executions have child executions. In that case, the
// flow scope hierarchy is not aligned with the scope execution hierarchy: There is a scope
// execution for a compensation-throwing event that is an ancestor of this execution,
// while these events are not ancestor scopes of currentScope.
//
// The strategy to deal with this situation is as follows:
// 1. Determine all executions that correspond to leaf activity instances
// 2. Order the leaf executions in top-to-bottom fashion
// 3. Iteratively build the activity execution mapping based on the leaves in top-to-bottom order
// 3.1. For the first leaf, create the activity execution mapping regularly
// 3.2. For every following leaf, rebuild the mapping but reuse any scopes and scope executions
// that are part of the mapping created in the previous iteration
//
// This process ensures that the resulting mapping does not contain scopes that are not ancestors
// of currentScope and that it does not contain scope executions for such scopes.
// For any execution hierarchy that does not involve compensation, the number of iterations in step 3
// should be 1, i.e. there are no other leaf activity instance executions in the hierarchy.
// 1. Find leaf activity instance executions
$leafCollector = new LeafActivityInstanceExecutionCollector();
(new ExecutionWalker($this))->addPreVisitor($leafCollector)->walkUntil();
$leafCollector->removeLeaf($this);
$leaves = $leafCollector->getLeaves();
// 2. Order them from top to bottom
$leaves = array_reverse($leaves);
// 3. Iteratively extend the mapping for every additional leaf
$mapping = [];
foreach ($leaves as $leaf) {
$leafFlowScope = $leaf->getFlowScope();
$leafFlowScopeExecution = $leaf->getFlowScopeExecution();
$mapping = $leafFlowScopeExecution->createActivityExecutionMapping($leafFlowScope, $mapping);
}
// finally extend the mapping for the current execution
// (note that the current execution need not be a leaf itself)
$mapping = $this->createActivityExecutionMapping($currentScope, $mapping);
return $mapping;
} elseif ($currentScope === null && $mapping === null) {
$currentActivity = $this->getActivity();
EnsureUtil::ensureNotNull("activity of current execution", "currentActivity", $currentActivity);
$flowScope = $this->getFlowScope();
$flowScopeExecution = $this->getFlowScopeExecution();
return $flowScopeExecution->createActivityExecutionMapping($flowScope);
}
}
// toString /////////////////////////////////////////////////////////////////
public function __toString()
{
if ($this->isProcessInstanceExecution()) {
return "ProcessInstance[" . $this->getToStringIdentity() . "]";
} else {
return ($this->isConcurrent ? "Concurrent" : "") . ($this->isScope ? "Scope" : "") . "Execution[" . $this->getToStringIdentity() . "]";
}
}
protected function getToStringIdentity(): ?string
{
return $this->id;
}
// variables ////////////////////////////////////////////
public function getVariableScopeKey(): ?string
{
return "execution";
}
public function getParentVariableScope(): ?AbstractVariableScope
{
return $this->getParent();
}
/*public function setVariable(?string $variableName, $value, ...$args): void
{
$activityId = $this->getActivityId();
if (!empty($args) && is_string($args[0])) {
$targetActivityId = $args[0];
} else {
$targetActivityId = null;
}
if (!empty($activityId) && $activityId == $targetActivityId) {
$this->setVariableLocal($variableName, $value);
} else {
$executionForFlowScope = $this->findExecutionForFlowScope($targetActivityId);
if ($executionForFlowScope !== null) {
$executionForFlowScope->setVariableLocal($variableName, $value);
}
}
}*/
// sequence counter ///////////////////////////////////////////////////////////
public function getSequenceCounter(): int
{
return $this->sequenceCounter;
}
public function setSequenceCounter(int $sequenceCounter): void
{
$this->sequenceCounter = $sequenceCounter;
}
public function incrementSequenceCounter(): void
{
$this->sequenceCounter += 1;
}
// Getter / Setters ///////////////////////////////////
public function isExternallyTerminated(): bool
{
return $this->externallyTerminated;
}
public function setExternallyTerminated(bool $externallyTerminated): void
{
$this->externallyTerminated = $externallyTerminated;
}
public function getDeleteReason(): ?string
{
return $this->deleteReason;
}
public function setDeleteReason(?string $deleteReason): void
{
$this->deleteReason = $deleteReason;
}
public function isDeleteRoot(): bool
{
return $this->deleteRoot;
}
public function setDeleteRoot(bool $deleteRoot): void
{
$this->deleteRoot = $deleteRoot;
}
public function getTransition(): ?TransitionImpl
{
return $this->transition;
}
public function getTransitionsToTake(): array
{
return $this->transitionsToTake;
}
public function setTransitionsToTake(?array $transitionsToTake = []): void
{
$this->transitionsToTake = $transitionsToTake;
}
public function getCurrentTransitionId(): ?string
{
$transition = $this->getTransition();
if ($transition !== null) {
return $transition->getId();
}
return null;
}
public function setTransition(?PvmTransitionInterface $transition): void
{
$this->transition = $transition;
}
public function isConcurrent(): bool
{
return $this->isConcurrent;
}
public function setConcurrent(bool $isConcurrent): void
{
$this->isConcurrent = $isConcurrent;
}
public function setActive(bool $isActive): void
{
$this->isActive = $isActive;
}
public function setEnded(bool $isEnded): void
{
$this->isEnded = $isEnded;
}
public function isEnded(): bool
{
return $this->isEnded;
}
public function isCanceled(): bool
{
return ActivityInstanceState::canceled()->getStateCode() == $this->activityInstanceState;
}
public function setCanceled(bool $canceled): void
{
if ($canceled) {
$this->activityInstanceState = ActivityInstanceState::canceled()->getStateCode();
}
}
public function isCompleteScope(): bool
{
return ActivityInstanceState::scopeComplete()->getStateCode() == $this->activityInstanceState;
}
public function setCompleteScope(bool $completeScope): void
{
if ($completeScope && !$this->isCanceled()) {
$this->activityInstanceState = ActivityInstanceState::scopeComplete()->getStateCode();
}
}
public function setPreserveScope(bool $preserveScope): void
{
$this->preserveScope = $preserveScope;
}
public function isPreserveScope(): bool
{
return $this->preserveScope;
}
public function getActivityInstanceState(): int
{
return $this->activityInstanceState;
}
public function isInState(ActivityInstanceState $state): bool
{
return $this->activityInstanceState == $state->getStateCode();
}
public function hasFailedOnEndListeners(): bool
{
return $this->activityInstanceEndListenersFailed;
}
public function isEventScope(): bool
{
return $this->isEventScope;
}
public function setEventScope(bool $isEventScope): void
{
$this->isEventScope = $isEventScope;
}
public function getScopeInstantiationContext(): ?ScopeInstantiationContext
{
return $this->scopeInstantiationContext;
}
public function disposeScopeInstantiationContext(): void
{
$this->scopeInstantiationContext = null;
$parent = $this;
while (($parent = $parent->getParent()) !== null && $parent->scopeInstantiationContext !== null) {
$parent->scopeInstantiationContext = null;
}
}
public function getNextActivity(): PvmActivityInterface
{
return $this->nextActivity;
}
public function isProcessInstanceExecution(): bool
{
return $this->getParent() === null;
}
public function setStartContext(?ScopeInstantiationContext $startContext): void
{
$this->scopeInstantiationContext = $startContext;
}
public function setIgnoreAsync(bool $ignoreAsync): void
{
$this->ignoreAsync = $ignoreAsync;
}
public function isIgnoreAsync(): bool
{
return $this->ignoreAsync;
}
public function setStarting(bool $isStarting): void
{
$this->isStarting = $isStarting;
}
public function isStarting(): bool
{
return $this->isStarting;
}
public function isProcessInstanceStarting(): bool
{
return $this->getProcessInstance()->isStarting();
}
public function setProcessInstanceStarting(bool $starting): void
{
$this->getProcessInstance()->setStarting($starting);
}
public function setNextActivity(?PvmActivityInterface $nextActivity): void
{
$this->nextActivity = $nextActivity;
}
public function getParentScopeExecution(bool $considerSuperExecution): PvmExecutionImpl
{
if ($this->isProcessInstanceExecution()) {
if ($considerSuperExecution && $this->getSuperExecution() !== null) {
$superExecution = $this->getSuperExecution();
if ($superExecution->isScope()) {
return $superExecution;
} else {
return $superExecution->getParent();
}
} else {
return null;
}
} else {
$parent = $this->getParent();
if ($parent->isScope()) {
return $parent;
} else {
return $parent->getParent();
}
}
}
/**
* Contains the delayed variable events, which will be dispatched on a save point.
*/
protected $delayedEvents = [];
/**
* Delays and stores the given DelayedVariableEvent on the process instance.
*
* @param delayedVariableEvent the DelayedVariableEvent which should be store on the process instance
*/
public function delayEvent($target, ?VariableEvent $variableEvent = null): void
{
if ($target instanceof PvmExecutionImpl) {
$delayedVariableEvent = new DelayedVariableEvent($target, $variableEvent);
$this->delayEvent($delayedVariableEvent);
} elseif ($target instanceof DelayedVariableEvent) {
//if process definition has no conditional events the variable events does not have to be delayed
$hasConditionalEvents = $this->getProcessDefinition()->getProperties()->get(BpmnProperties::hasConditionalEvents());
if ($hasConditionalEvents === null || $hasConditionalEvents != true) {
return;
}
if ($this->isProcessInstanceExecution()) {
$this->delayedEvents[] = $target;
} else {
$this->getProcessInstance()->delayEvent($target);
}
}
}
/**
* The current delayed variable events.
*
* @return a list of DelayedVariableEvent objects
*/
public function getDelayedEvents(): array
{
if ($this->isProcessInstanceExecution()) {
return $this->delayedEvents;
}
return $this->getProcessInstance()->getDelayedEvents();
}
/**
* Cleares the current delayed variable events.
*/
public function clearDelayedEvents(): void
{
if ($this->isProcessInstanceExecution()) {
$this->delayedEvents = [];
} else {
$this->getProcessInstance()->clearDelayedEvents();
}
}
/**
* Dispatches the current delayed variable events and performs the given atomic operation
* if the current state was not changed.
*
* @param continuation the atomic operation continuation which should be executed
*/
public function dispatchDelayedEventsAndPerformOperation($continuation = null): void
{
if ($continuation instanceof PvmAtomicOperationInterface) {
$this->dispatchDelayedEventsAndPerformOperation(new class ($continuation) implements CallbackInterface {
private $atomicOperation;
public function __construct(PvmAtomicOperationInterface $atomicOperation)
{
$this->atomicOperation = $atomicOperation;
}
public function callback($param)
{
$param->performOperation($this->atomicOperation);
return null;
}
});
} elseif ($continuation instanceof CallbackInterface) {
$execution = $this;
if (empty($execution->getDelayedEvents())) {
$this->continueExecutionIfNotCanceled($continuation, $execution);
return;
}
$this->continueIfExecutionDoesNotAffectNextOperation(new class ($this) implements CallbackInterface {
private $scope;
public function __construct(PvmExecutionImpl $scope)
{
$this->scope = $scope;
}
public function callback(PvmExecutionImpl $execution)
{
$this->scope->dispatchScopeEvents($execution);
return null;
}
}, new class () implements CallbackInterface {
private $scope;
private $continuation;
public function __construct(PvmExecutionImpl $scope, $continuation)
{
$this->scope = $scope;
$this->continuation = $continuation;
}
public function callback(PvmExecutionImpl $execution)
{
$this->scope->continueExecutionIfNotCanceled($this->continuation, $execution);
return null;
}
}, $execution);
}
}
/**
* Executes the given depending operations with the given execution.
* The execution state will be checked with the help of the activity instance id and activity id of the execution before and after
* the dispatching callback call. If the id's are not changed the
* continuation callback is called.
*
* @param dispatching the callback to dispatch the variable events
* @param continuation the callback to continue with the next atomic operation
* @param execution the execution which is used for the execution
*/
public function continueIfExecutionDoesNotAffectNextOperation(
CallbackInterface $dispatching,
CallbackInterface $continuation,
PvmExecutionImpl $execution
): void {
$lastActivityId = $execution->getActivityId();
$lastActivityInstanceId = $this->getActivityInstanceId($execution);
$dispatching->callback($execution);
$execution = $execution->getReplacedBy() !== null ? $execution->getReplacedBy() : $execution;
$currentActivityInstanceId = $this->getActivityInstanceId($execution);
$currentActivityId = $execution->getActivityId();
//if execution was canceled or was changed during the dispatch we should not execute the next operation
//since another atomic operation was executed during the dispatching
if (!$execution->isCanceled() && $this->isOnSameActivity($lastActivityInstanceId, $lastActivityId, $currentActivityInstanceId, $currentActivityId)) {
$continuation->callback($execution);
}
}
protected function continueExecutionIfNotCanceled(?CallbackInterface $continuation, PvmExecutionImpl $execution): void
{
if ($continuation !== null && !$execution->isCanceled()) {
$continuation->callback($execution);
}
}
/**
* Dispatches the current delayed variable events on the scope of the given execution.
*
* @param execution the execution on which scope the delayed variable should be dispatched
*/
protected function dispatchScopeEvents(PvmExecutionImpl $execution): void
{
$scopeExecution = $execution->isScope() ? $execution : $execution->getParent();
$delayedEvents = $scopeExecution->getDelayedEvents();
$scopeExecution->clearDelayedEvents();
$activityInstanceIds = [];
$activityIds = [];
$this->initActivityIds($delayedEvents, $activityInstanceIds, $activityIds);
//For each delayed variable event we have to check if the delayed event can be dispatched,
//the check will be done with the help of the activity id and activity instance id.
//That means it will be checked if the dispatching changed the execution tree in a way that we can't dispatch the
//the other delayed variable events. We have to check the target scope with the last activity id and activity instance id
//and also the replace pointer if it exist. Because on concurrency the replace pointer will be set on which we have
//to check the latest state.
foreach ($delayedEvents as $event) {
$targetScope = $event->getTargetScope();
$replaced = $targetScope->getReplacedBy() !== null ? $targetScope->getReplacedBy() : $targetScope;
$this->dispatchOnSameActivity($targetScope, $replaced, $activityIds, $activityInstanceIds, $event);
}
}
/**
* Initializes the given maps with the target scopes and current activity id's and activity instance id's.
*
* @param delayedEvents the delayed events which contains the information about the target scope
* @param activityInstanceIds the map which maps target scope to activity instance id
* @param activityIds the map which maps target scope to activity id
*/
protected function initActivityIds(
array $delayedEvents,
array &$activityInstanceIds,
array &$activityIds
): void {
foreach ($delayedEvents as $event) {
$targetScope = $event->getTargetScope();
$targetScopeActivityInstanceId = $this->getActivityInstanceId($targetScope);
$activityInstanceIds[] = [$targetScope, $targetScopeActivityInstanceId];
$activityIds[] = [$targetScope, $targetScope->getActivityId()];
}
}
/**
* Dispatches the delayed variable event, if the target scope and replaced by scope (if target scope was replaced) have the
* same activity Id's and activity instance id's.
*
* @param targetScope the target scope on which the event should be dispatched
* @param replacedBy the replaced by pointer which should have the same state
* @param activityIds the map which maps scope to activity id
* @param activityInstanceIds the map which maps scope to activity instance id
* @param delayedVariableEvent the delayed variable event which should be dispatched
*/
private function dispatchOnSameActivity(
PvmExecutionImpl $targetScope,
PvmExecutionImpl $replacedBy,
array $activityIds,
array $activityInstanceIds,
DelayedVariableEvent $delayedVariableEvent
): void {
//check if the target scope has the same activity id and activity instance id
//since the dispatching was started
$currentActivityInstanceId = $this->getActivityInstanceId($targetScope);
$currentActivityId = $targetScope->getActivityId();
$lastActivityInstanceId = null;
foreach ($activityInstanceIds as $map) {
if ($map[0] == $targetScope) {
$lastActivityInstanceId = $map[1];
}
}
$lastActivityId = null;
foreach ($activityIds as $map) {
if ($map[0] == $targetScope) {
$lastActivityId = $map[1];
}
}
$onSameAct = $this->isOnSameActivity($lastActivityInstanceId, $lastActivityId, $currentActivityInstanceId, $currentActivityId);
//If not we have to check the replace pointer,
//which was set if a concurrent execution was created during the dispatching.
if ($targetScope != $replacedBy && !$onSameAct) {
$currentActivityInstanceId = $this->getActivityInstanceId($replacedBy);
$currentActivityId = $replacedBy->getActivityId();
$onSameAct = $this->isOnSameActivity($lastActivityInstanceId, $lastActivityId, $currentActivityInstanceId, $currentActivityId);
}
//dispatching
if ($onSameAct && $this->isOnDispatchableState($targetScope)) {
$targetScope->dispatchEvent($delayedVariableEvent->getEvent());
}
}
/**
* Checks if the given execution is on a dispatchable state.
* That means if the current activity is not a leaf in the activity tree OR
* it is a leaf but not a scope OR it is a leaf, a scope
* and the execution is in state DEFAULT, which means not in state
* Starting, Execute or Ending. For this states it is
* prohibited to trigger conditional events, otherwise unexpected behavior can appear.
*
* @return bool - true if the execution is on a dispatchable state, false otherwise
*/
private function isOnDispatchableState(PvmExecutionImpl $targetScope): bool
{
$targetActivity = $targetScope->getActivity();
return
//if not leaf, activity id is null -> dispatchable
$targetScope->getActivityId() === null ||
// if leaf and not scope -> dispatchable
!$targetActivity->isScope() ||
// if leaf, scope and state in default -> dispatchable
($targetScope->isInState(ActivityInstanceState::default()));
}
/**
* Compares the given activity instance id's and activity id's to check if the execution is on the same
* activity as before an operation was executed. The activity instance id's can be null on transitions.
* In this case the activity Id's have to be equal, otherwise the execution changed.
*
* @param string|null - lastActivityInstanceId the last activity instance id
* @param string|null - lastActivityId the last activity id
* @param string|null - currentActivityInstanceId the current activity instance id
* @param string|null - currentActivityId the current activity id
* @return bool - true if the execution is on the same activity, otherwise false
*/
private function isOnSameActivity(
?string $lastActivityInstanceId,
?string $lastActivityId,
?string $currentActivityInstanceId,
?string $currentActivityId
): bool {
return
//activityInstanceId's can be null on transitions, so the activityId must be equal
(($lastActivityInstanceId === null && $lastActivityInstanceId == $currentActivityInstanceId && $lastActivityId == $currentActivityId)
//if activityInstanceId's are not null they must be equal -> otherwise execution changed
|| ($lastActivityInstanceId !== null && $lastActivityInstanceId == $currentActivityInstanceId
&& ($lastActivityId === null || $lastActivityId == $currentActivityId)));
}
/**
* Returns the activity instance id for the given execution.
*
* @param PvmExecutionImpl|null - targetScope the execution for which the activity instance id should be returned
* @return string the activity instance id
*/
public function getActivityInstanceId(/*PvmExecutionImpl*/...$args): ?string
{
$targetScope = null;
if (!empty($args)) {
$targetScope = $args[0];
}
if ($targetScope !== null) {
if ($targetScope->isConcurrent()) {
return $targetScope->getActivityInstanceId();
} else {
$targetActivity = $targetScope->getActivity();
if (($targetActivity !== null && empty($targetActivity->getActivities()))) {
return $targetScope->getActivityInstanceId();
}
return $targetScope->getParentActivityInstanceId();
}
}
return $this->activityInstanceId;
}
/**
* Returns the newest incident in this execution
*
* @param incidentType the type of new incident
* @param configuration configuration of the incident
* @return new incident
*/
public function createIncident(?string $incidentType, ?string $configuration, ?string $message = null): IncidentInterface
{
$incidentContext = $this->createIncidentContext($configuration);
return IncidentHandling::createIncident($incidentType, $incidentContext, $message);
}
protected function createIncidentContext(?string $configuration): IncidentContext
{
$incidentContext = new IncidentContext();
$incidentContext->setTenantId($this->getTenantId());
$incidentContext->setProcessDefinitionId($this->getProcessDefinitionId());
$incidentContext->setExecutionId($this->getId());
$incidentContext->setActivityId($this->getActivityId());
$incidentContext->setConfiguration($configuration);
return $incidentContext;
}
/**
* Resolves an incident with given id.
*
* @param incidentId
*/
public function resolveIncident(?string $incidentId): void
{
$incident = Context::getCommandContext()
->getIncidentManager()
->findIncidentById($incidentId);
$incidentContext = new IncidentContext($incident);
IncidentHandling::removeIncidents($incident->getIncidentType(), $incidentContext, true);
}
public function findIncidentHandler(?string $incidentType): ?IncidentHandlerInterface
{
$incidentHandlers = Context::getProcessEngineConfiguration()->getIncidentHandlers();
if (array_key_exists($incidentType, $incidentHandlers)) {
return $incidentHandlers[$incidentType];
}
return null;
}
}
| 40,606
|
https://github.com/AmpersandJS/ampersand-events/blob/master/test/index.js
|
Github Open Source
|
Open Source
|
MIT
| 2,019
|
ampersand-events
|
AmpersandJS
|
JavaScript
|
Code
| 1,986
| 6,143
|
var test = require('tape');
var assign = require('lodash/assign');
var keys = require('lodash/keys');
var size = require('lodash/size');
var debounce = require('lodash/debounce');
var Events = require('../ampersand-events');
test('on and trigger', function (t) {
t.plan(2);
var obj = {
counter: 0
};
assign(obj, Events);
obj.on('event', function () {
obj.counter += 1;
});
obj.trigger('event');
t.equal(obj.counter,1,'counter should be incremented.');
obj.trigger('event');
obj.trigger('event');
obj.trigger('event');
obj.trigger('event');
t.equal(obj.counter, 5, 'counter should be incremented five times.');
t.end();
});
test('bind/unbind and trigger (for backwards compatibility)', function (t) {
t.plan(3);
var obj = {
counter: 0
};
assign(obj, Events);
obj.bind('event', function () {
obj.counter += 1;
});
obj.trigger('event');
t.equal(obj.counter,1,'counter should be incremented.');
obj.trigger('event');
obj.trigger('event');
obj.trigger('event');
obj.trigger('event');
t.equal(obj.counter, 5, 'counter should be incremented five times.');
obj.unbind('event');
obj.trigger('event');
t.equal(obj.counter, 5, 'counter should not be further incremented as unbound.');
t.end();
});
test('binding and triggering multiple events', function (t) {
t.plan(4);
var obj = { counter: 0 };
assign(obj, Events);
obj.on('a b c', function () { obj.counter += 1; });
obj.trigger('a');
t.equal(obj.counter, 1);
obj.trigger('a b');
t.equal(obj.counter, 3);
obj.trigger('c');
t.equal(obj.counter, 4);
obj.off('a c');
obj.trigger('a b c');
t.equal(obj.counter, 5);
t.end();
});
test('binding and triggering with event maps', function (t) {
var obj = { counter: 0 };
assign(obj, Events);
var increment = function () {
this.counter += 1;
};
obj.on({
a: increment,
b: increment,
c: increment
}, obj);
obj.trigger('a');
t.equal(obj.counter, 1);
obj.trigger('a b');
t.equal(obj.counter, 3);
obj.trigger('c');
t.equal(obj.counter, 4);
obj.off({
a: increment,
c: increment
}, obj);
obj.trigger('a b c');
t.equal(obj.counter, 5);
t.end();
});
test('listenTo and stopListening', function (t) {
t.plan(1);
var a = assign({}, Events);
var b = assign({}, Events);
a.listenTo(b, 'all', function () { t.ok(true); });
b.trigger('anything');
a.listenTo(b, 'all', function () { t.ok(false); });
a.stopListening();
b.trigger('anything');
t.end();
});
test('listenTo and stopListening with event maps', function (t) {
t.plan(4);
var a = assign({}, Events);
var b = assign({}, Events);
var cb = function () { t.ok(true); };
a.listenTo(b, {event: cb});
b.trigger('event');
a.listenTo(b, {event2: cb});
b.on('event2', cb);
a.stopListening(b, {event2: cb});
b.trigger('event event2');
a.stopListening();
b.trigger('event event2');
t.end();
});
test('stopListening with omitted args', function (t) {
t.plan(2);
var a = assign({}, Events);
var b = assign({}, Events);
var cb = function () { t.ok(true); };
a.listenTo(b, 'event', cb);
b.on('event', cb);
a.listenTo(b, 'event2', cb);
a.stopListening(null, {event: cb});
b.trigger('event event2');
b.off();
a.listenTo(b, 'event event2', cb);
a.stopListening(null, 'event');
a.stopListening();
b.trigger('event2');
t.end();
});
test('listenToOnce and stopListening', function (t) {
t.plan(1);
var a = assign({}, Events);
var b = assign({}, Events);
a.listenToOnce(b, 'all', function () { t.ok(true); });
b.trigger('anything');
b.trigger('anything');
a.listenToOnce(b, 'all', function () { t.ok(false); });
a.stopListening();
b.trigger('anything');
t.end();
});
test('listenTo, listenToOnce and stopListening', function (t) {
t.plan(1);
var a = assign({}, Events);
var b = assign({}, Events);
a.listenToOnce(b, 'all', function () { t.ok(true); });
b.trigger('anything');
b.trigger('anything');
a.listenTo(b, 'all', function () { t.ok(false); });
a.stopListening();
b.trigger('anything');
t.end();
});
test('listenTo and stopListening with event maps', function (t) {
t.plan(1);
var a = assign({}, Events);
var b = assign({}, Events);
a.listenTo(b, {change: function () { t.ok(true); }});
b.trigger('change');
a.listenTo(b, {change: function () { t.ok(false); }});
a.stopListening();
b.trigger('change');
t.end();
});
test('listenTo yourself', function (t) {
t.plan(1);
var e = assign({}, Events);
e.listenTo(e, 'foo', function () { t.ok(true); });
e.trigger('foo');
t.end();
});
test('listenTo yourself cleans yourself up with stopListening', function (t) {
t.plan(1);
var e = assign({}, Events);
e.listenTo(e, 'foo', function () { t.ok(true); });
e.trigger('foo');
e.stopListening();
e.trigger('foo');
t.end();
});
test('stopListening cleans up references', function (t) {
t.plan(4);
var a = assign({}, Events);
var b = assign({}, Events);
var fn = function () {};
a.listenTo(b, 'all', fn).stopListening();
t.equal(size(a._listeningTo), 0);
a.listenTo(b, 'all', fn).stopListening(b);
t.equal(size(a._listeningTo), 0);
a.listenTo(b, 'all', fn).stopListening(null, 'all');
t.equal(size(a._listeningTo), 0);
a.listenTo(b, 'all', fn).stopListening(null, null, fn);
t.equal(size(a._listeningTo), 0);
t.end();
});
test('listenTo and stopListening cleaning up references', function (t) {
t.plan(2);
var a = assign({}, Events);
var b = assign({}, Events);
a.listenTo(b, 'all', function () { t.ok(true); });
b.trigger('anything');
a.listenTo(b, 'other', function () { t.ok(false); });
a.stopListening(b, 'other');
a.stopListening(b, 'all');
t.equal(keys(a._listeningTo).length, 0);
t.end();
});
test('listenTo with empty callback doesn\'t throw an error', function (t) {
t.plan(1);
var e = assign({}, Events);
e.listenTo(e, 'foo', null);
e.trigger('foo');
t.ok(true);
t.end();
});
test('trigger all for each event', function (t) {
t.plan(3);
var a, b, obj = { counter: 0 };
assign(obj, Events);
obj.on('all', function(event) {
obj.counter++;
if (event == 'a') a = true;
if (event == 'b') b = true;
})
.trigger('a b');
t.ok(a);
t.ok(b);
t.equal(obj.counter, 2);
t.end();
});
test('on, then unbind all functions', function (t) {
t.plan(1);
var obj = { counter: 0 };
assign(obj,Events);
var callback = function () { obj.counter += 1; };
obj.on('event', callback);
obj.trigger('event');
obj.off('event');
obj.trigger('event');
t.equal(obj.counter, 1, 'counter should have only been incremented once.');
t.end();
});
test('bind two callbacks, unbind only one', function (t) {
t.plan(2);
var obj = { counterA: 0, counterB: 0 };
assign(obj,Events);
var callback = function () { obj.counterA += 1; };
obj.on('event', callback);
obj.on('event', function () { obj.counterB += 1; });
obj.trigger('event');
obj.off('event', callback);
obj.trigger('event');
t.equal(obj.counterA, 1, 'counterA should have only been incremented once.');
t.equal(obj.counterB, 2, 'counterB should have been incremented twice.');
t.end();
});
test('unbind a callback in the midst of it firing', function (t) {
t.plan(1);
var obj = {counter: 0};
assign(obj, Events);
var callback = function () {
obj.counter += 1;
obj.off('event', callback);
};
obj.on('event', callback);
obj.trigger('event');
obj.trigger('event');
obj.trigger('event');
t.equal(obj.counter, 1, 'the callback should have been unbound.');
t.end();
});
test('two binds that unbind themeselves', function (t) {
t.plan(2);
var obj = { counterA: 0, counterB: 0 };
assign(obj,Events);
var incrA = function () { obj.counterA += 1; obj.off('event', incrA); };
var incrB = function () { obj.counterB += 1; obj.off('event', incrB); };
obj.on('event', incrA);
obj.on('event', incrB);
obj.trigger('event');
obj.trigger('event');
obj.trigger('event');
t.equal(obj.counterA, 1, 'counterA should have only been incremented once.');
t.equal(obj.counterB, 1, 'counterB should have only been incremented once.');
t.end();
});
test('bind a callback with a supplied context', function (t) {
t.plan(1);
var TestClass = function () {
return this;
};
TestClass.prototype.assertTrue = function () {
t.ok(true, '`this` was bound to the callback');
};
var obj = assign({},Events);
obj.on('event', function () { this.assertTrue(); }, (new TestClass()));
obj.trigger('event');
t.end();
});
test('nested trigger with unbind', function (t) {
t.plan(1);
var obj = { counter: 0 };
assign(obj, Events);
var incr1 = function () { obj.counter += 1; obj.off('event', incr1); obj.trigger('event'); };
var incr2 = function () { obj.counter += 1; };
obj.on('event', incr1);
obj.on('event', incr2);
obj.trigger('event');
t.equal(obj.counter, 3, 'counter should have been incremented three times');
t.end();
});
test('callback list is not altered during trigger', function (t) {
t.plan(2);
var counter = 0, obj = assign({}, Events);
var incr = function () { counter++; };
obj.on('event', function () { obj.on('event', incr).on('all', incr); })
.trigger('event');
t.equal(counter, 0, 'bind does not alter callback list');
obj.off()
.on('event', function () { obj.off('event', incr).off('all', incr); })
.on('event', incr)
.on('all', incr)
.trigger('event');
t.equal(counter, 2, 'unbind does not alter callback list');
t.end();
});
test('#1282 - `all` callback list is retrieved after each event.', function (t) {
t.plan(1);
var counter = 0;
var obj = assign({}, Events);
var incr = function () { counter++; };
obj.on('x', function () {
obj.on('y', incr).on('all', incr);
})
.trigger('x y');
t.strictEqual(counter, 2);
t.end();
});
test('if no callback is provided, `on` is a noop', function (t) {
t.plan(0);
assign({}, Events).on('test').trigger('test');
t.end();
});
test('if callback is truthy but not a function, `on` should throw an error just like jQuery', function (t) {
t.plan(1);
var view = assign({}, Events).on('test', 'noop');
t.throws(function () {
view.trigger('test');
});
t.end();
});
test('remove all events for a specific context', function (t) {
t.plan(4);
var obj = assign({}, Events);
obj.on('x y all', function () { t.ok(true); });
obj.on('x y all', function () { t.ok(false); }, obj);
obj.off(null, null, obj);
obj.trigger('x y');
t.end();
});
test('remove all events for a specific callback', function (t) {
t.plan(4);
var obj = assign({}, Events);
var success = function () { t.ok(true); };
var fail = function () { t.ok(false); };
obj.on('x y all', success);
obj.on('x y all', fail);
obj.off(null, fail);
obj.trigger('x y');
t.end();
});
test('#1310 - off does not skip consecutive events', function (t) {
t.plan(0);
var obj = assign({}, Events);
obj.on('event', function () {
t.ok(false);
}, obj);
obj.on('event', function () {
t.ok(false);
}, obj);
obj.off(null, null, obj);
obj.trigger('event');
t.end();
});
test('once', function (t) {
t.plan(2);
// Same as the previous test, but we use once rather than having to explicitly unbind
var obj = { counterA: 0, counterB: 0 };
assign(obj, Events);
var incrA = function () { obj.counterA += 1; obj.trigger('event'); };
var incrB = function () { obj.counterB += 1; };
obj.once('event', incrA);
obj.once('event', incrB);
obj.trigger('event');
t.equal(obj.counterA, 1, 'counterA should have only been incremented once.');
t.equal(obj.counterB, 1, 'counterB should have only been incremented once.');
t.end();
});
test('once variant one', function (t) {
t.plan(3);
var f = function () { t.ok(true); };
var a = assign({}, Events).once('event', f);
var b = assign({}, Events).on('event', f);
a.trigger('event');
b.trigger('event');
b.trigger('event');
t.end();
});
test('once variant two', function (t) {
t.plan(3);
var f = function () { t.ok(true); };
var obj = assign({}, Events);
obj
.once('event', f)
.on('event', f)
.trigger('event')
.trigger('event');
t.end();
});
test('once with off', function (t) {
t.plan(0);
var f = function () { t.ok(true); };
var obj = assign({}, Events);
obj.once('event', f);
obj.off('event', f);
obj.trigger('event');
t.end();
});
test('once with event maps', function (t) {
var obj = { counter: 0 };
assign(obj, Events);
var increment = function () {
this.counter += 1;
};
obj.once({
a: increment,
b: increment,
c: increment
}, obj);
obj.trigger('a');
t.equal(obj.counter, 1);
obj.trigger('a b');
t.equal(obj.counter, 2);
obj.trigger('c');
t.equal(obj.counter, 3);
obj.trigger('a b c');
t.equal(obj.counter, 3);
t.end();
});
test('bind a callback with a supplied context when using once', function (t) {
t.plan(1);
var TestClass = function () {
return this;
};
TestClass.prototype.assertTrue = function () {
t.ok(true, '`this` was bound to the callback');
};
var obj = assign({},Events);
obj.once('event', function () { this.assertTrue(); }, (new TestClass()));
obj.trigger('event');
t.end();
});
test('once with off only by context', function (t) {
t.plan(0);
var context = {};
var obj = assign({}, Events);
obj.once('event', function () { t.ok(false); }, context);
obj.off(null, null, context);
obj.trigger('event');
t.end();
});
test('once with asynchronous events', function (t) {
t.plan(1);
var func = debounce(function () { t.ok(true); t.end(); }, 50);
var obj = assign({}, Events).once('async', func);
obj.trigger('async');
obj.trigger('async');
});
test('once with multiple events.', function (t) {
t.plan(2);
var obj = assign({}, Events);
obj.once('x y', function () { t.ok(true); });
obj.trigger('x y');
t.end();
});
test('Off during iteration with once.', function (t) {
t.plan(2);
var obj = assign({}, Events);
var f = function () { this.off('event', f); };
obj.on('event', f);
obj.once('event', function () {});
obj.on('event', function () { t.ok(true); });
obj.trigger('event');
obj.trigger('event');
t.end();
});
test('`once` on `all` should work as expected', function (t) {
t.plan(1);
var thing = assign({}, Events);
thing.once('all', function () {
t.ok(true);
thing.trigger('all');
});
thing.trigger('all');
t.end();
});
test('once without a callback is a noop', function (t) {
t.plan(0);
assign({}, Events).once('event').trigger('event');
t.end();
});
test('event functions are chainable', function (t) {
var obj = assign({}, Events);
var obj2 = assign({}, Events);
var fn = function () {};
t.equal(obj, obj.trigger('noeventssetyet'));
t.equal(obj, obj.off('noeventssetyet'));
t.equal(obj, obj.stopListening('noeventssetyet'));
t.equal(obj, obj.on('a', fn));
t.equal(obj, obj.once('c', fn));
t.equal(obj, obj.trigger('a'));
t.equal(obj, obj.listenTo(obj2, 'a', fn));
t.equal(obj, obj.listenToOnce(obj2, 'b', fn));
t.equal(obj, obj.off('a c'));
t.equal(obj, obj.stopListening(obj2, 'a'));
t.equal(obj, obj.stopListening());
t.end();
});
test('listenToAndRun', function (t) {
var count = 0;
var a = assign({}, Events);
var b = assign({}, Events);
var result = a.listenToAndRun(b, 'all', function () {
count++;
t.equal(this, a, 'context should always be `a`');
});
t.equal(result, a, 'should return object');
t.equal(count, 1, 'should have been called right away');
b.trigger('anything');
t.equal(count, 2, 'should have been called when triggered');
t.equal(keys(a._listeningTo).length, 1, 'should have one object being listened to.');
// stop it all
a.stopListening();
// trigger to see
b.trigger('anything');
t.equal(count, 2, 'should not have triggered again');
t.equal(keys(a._listeningTo).length, 0, 'should have no objects being listened to.');
t.end();
});
test('createEmitter', function (t) {
t.ok(Events.createEmitter().on, 'can create new empty emitters');
var myObj = {};
Events.createEmitter(myObj);
t.ok(myObj.on, 'adds event methods to existing objects if passed');
t.end();
});
test('throws a useful error if listening to an undefined object with listenTo', function (t) {
t.plan(1);
var view = assign({}, Events);
t.throws(function () {
view.listenTo(undefined, 'test', function () {});
}, /Trying to listenTo event: 'test'/);
t.end();
});
test('throws a useful error if listening to a non-bindable object with listenTo', function (t) {
t.plan(1);
var view = assign({}, Events);
t.throws(function () {
view.listenTo(5, 'test', function () {});
}, /Trying to listenTo event: 'test'/);
t.end();
});
| 13,365
|
https://github.com/yahoo/messenger-sdk/blob/master/YahooMessengerLibraries/build/preprocessed/com/yahoo/messenger/util/YahooMessengerYTLoginUtilities.java
|
Github Open Source
|
Open Source
|
BSD-3-Clause
| 2,016
|
messenger-sdk
|
yahoo
|
Java
|
Code
| 268
| 919
|
/**
* Copyright (c) 2009-2010, Yahoo! Inc. All rights reserved.
* Code licensed under the BSD License:
* http://searchmarketing.yahoo.com/developer/docs/license.txt
*/
package com.yahoo.messenger.util;
import com.yahoo.messenger.exception.MessengerException;
import com.yahoo.messenger.manager.data.SessionData;
import java.io.IOException;
public class YahooMessengerYTLoginUtilities {
public static String performLoginGetPwToken(String username, String password)
throws MessengerException, IOException
{
String cs = YahooMessengerConstants.pwTokenGetURL + "src=ymsgr&" +
"login=" + username + "&" +
"passwd=" + password;
String resultString = HttpUtils.performHttpGet(cs);
String[] nameValuePairs = StringUtils.tokenize(resultString, '\n', true);
if (nameValuePairs.length == 1) {
try {
if (Integer.parseInt(nameValuePairs[0]) == 100) // NO USERNAME GIVEN
throw new MessengerException(MessengerException.NO_USERNAME_GIVEN);
else if (Integer.parseInt(nameValuePairs[0]) == 1235) // UNKNOWN USERNAME
throw new MessengerException(MessengerException.UNKNOWN_USERNAME, "Unknown username");
else if (Integer.parseInt(nameValuePairs[0]) == 1212) // INCORRECT PASSWORD
throw new MessengerException(MessengerException.INCORRECT_PASSWORD, "Incorrect password");
else // UNKNOWN ERROR
throw new MessengerException(MessengerException.UNKNOWN_ERROR, "Unknown error");
} catch (NumberFormatException e) {
throw new MessengerException(MessengerException.UNKNOWN_ERROR, "Unknown error");
}
} else if (nameValuePairs.length == 3) {
String token = StringUtils.getValue(nameValuePairs[1], "ymsg");
return token;
} else {
throw new MessengerException(MessengerException.UNKNOWN_ERROR, "Unknown error");
}
}
public static void performLoginGetYTCookie(SessionData loginData, String token)
throws MessengerException, IOException
{
String cs = YahooMessengerConstants.pwTokenLoginURL + "src=ymsgr&" + "token=" + token;
String resultString = HttpUtils.performHttpGet(cs);
String[] nameValuePairs = StringUtils.tokenize(resultString, '\n', true);
if (nameValuePairs.length == 1) {
try {
if (Integer.parseInt(nameValuePairs[0]) == 100) // INVALID TOKEN
throw new MessengerException(MessengerException.INVALID_TOKEN, "Invalid token");
else // UNKNOWN ERROR
throw new MessengerException(MessengerException.UNKNOWN_ERROR, "Unknown error");
} catch (NumberFormatException e) {
throw new MessengerException(MessengerException.UNKNOWN_ERROR, "Unknown error");
}
} else if (nameValuePairs.length == 6) {
// Assemble the Y and T name value pairs into the information needed
// for the cookie.
String cookie = nameValuePairs[2]+" "+nameValuePairs[3];
loginData.setCookie(cookie);
} else {
throw new MessengerException(MessengerException.UNKNOWN_ERROR, "Unknown error");
}
}
}
| 42,361
|
https://github.com/CoOwner/VisualPvP/blob/master/org/apache/maven/lifecycle/Scheduling.java
|
Github Open Source
|
Open Source
|
MIT
| null |
VisualPvP
|
CoOwner
|
Java
|
Code
| 123
| 419
|
package org.apache.maven.lifecycle;
import java.util.List;
import org.apache.maven.plugin.MojoExecution;
public class Scheduling
{
private String lifecycle;
private List<Schedule> schedules;
public Scheduling() {}
public Scheduling(String lifecycle, List<Schedule> schedules)
{
this.lifecycle = lifecycle;
this.schedules = schedules;
}
public String getLifecycle()
{
return lifecycle;
}
public void setLifecycle(String lifecycle)
{
this.lifecycle = lifecycle;
}
public List<Schedule> getSchedules()
{
return schedules;
}
public Schedule getSchedule(String phaseName)
{
if (phaseName == null)
{
return null;
}
for (Schedule schedule : schedules)
{
if (phaseName.equals(schedule.getPhase()))
{
return schedule;
}
}
return null;
}
public Schedule getSchedule(MojoExecution mojoExecution)
{
if (mojoExecution == null)
{
return null;
}
for (Schedule schedule : schedules)
{
if (schedule.appliesTo(mojoExecution))
{
return schedule;
}
}
return null;
}
public void setSchedules(List<Schedule> schedules)
{
this.schedules = schedules;
}
}
| 42,710
|
https://github.com/Adrijaned/oglPlaygorund/blob/master/docs/search/functions_3.js
|
Github Open Source
|
Open Source
|
MIT
| null |
oglPlaygorund
|
Adrijaned
|
JavaScript
|
Code
| 6
| 103
|
var searchData=
[
['filenotfoundexception',['FileNotFoundException',['../classFileNotFoundException.html#ad3ba1c0aea65a2ff0e3c7c2841346b66',1,'FileNotFoundException']]],
['finish',['finish',['../classShaderProgram.html#aea6359b565da251e456fd0020fa0e705',1,'ShaderProgram']]]
];
| 5,975
|
https://github.com/delta94/h.bilibili-rn/blob/master/src/bilibiliApi/apis/authApi.ts
|
Github Open Source
|
Open Source
|
MIT
| 2,020
|
h.bilibili-rn
|
delta94
|
TypeScript
|
Code
| 113
| 564
|
/* eslint-disable @typescript-eslint/no-unused-vars */
import {
BaseService,
Response,
POST,
BasePath,
FormUrlEncoded,
GET,
Query,
} from 'ts-retrofit';
import {
ApiEndponits,
FieldMapW,
QueryMapW,
AppAuthorize,
} from '../extensions';
import {
BiliBiliProtocol,
RSAPublicKeyResult,
AuthResult,
SSOResult,
} from '../typings';
import { apiConfig } from '../contact';
@BasePath('')
export class AuthService extends BaseService {
@POST(`${ApiEndponits.passport}api/v3/oauth2/login`)
@FormUrlEncoded
@AppAuthorize()
async login(
@FieldMapW()
query: any,
): Promise<Response<BiliBiliProtocol<AuthResult>>> {
return <Response<BiliBiliProtocol<AuthResult>>>{};
}
@GET(`${ApiEndponits.passport}login`)
async getEncryptKey(
@QueryMapW()
query = { act: 'getkey', _: Date.now().toString().substr(0, 10) },
): Promise<Response<RSAPublicKeyResult>> {
return <Response<RSAPublicKeyResult>>{};
}
@GET(`${ApiEndponits.kaaassNet}biliapi/user/sso`)
async freshSSO(
@Query('access_key')
accessToken: string,
@Query('appkey')
appkey: string,
): Promise<Response<BiliBiliProtocol<SSOResult>>> {
return <Response<BiliBiliProtocol<SSOResult>>>{};
}
@GET(`${ApiEndponits.api}login/sso`)
async SSO(
@Query('access_key')
accessToken: string,
@Query('appkey')
appkey: string = apiConfig.appkey,
): Promise<Response<BiliBiliProtocol<SSOResult>>> {
return <Response<BiliBiliProtocol<SSOResult>>>{};
}
}
| 2,847
|
https://github.com/forestbat/BloodArsenal/blob/master/src/main/java/arc/bloodarsenal/modifier/ModifierTracker.java
|
Github Open Source
|
Open Source
|
CC-BY-4.0
| 2,017
|
BloodArsenal
|
forestbat
|
Java
|
Code
| 489
| 1,727
|
package arc.bloodarsenal.modifier;
import WayofTime.bloodmagic.util.Utils;
import arc.bloodarsenal.BloodArsenal;
import net.minecraft.nbt.NBTTagCompound;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map.Entry;
public class ModifierTracker
{
public static HashMap<String, ModifierTracker> trackerMap = new HashMap<>();
public double counter = 0;
public static HashMap<IModifiable, HashMap<Class<? extends Modifier>, Double>> changeMap = new HashMap<>();
public final int[] COUNTERS_NEEDED;
private boolean isDirty = false;
protected String name;
private final Modifier modifier;
private ModifierTracker(Modifier modifier, int[] countersNeeded)
{
this.modifier = modifier;
COUNTERS_NEEDED = countersNeeded;
}
public static ModifierTracker newTracker(Modifier modifier, int[] countersNeeded)
{
ModifierTracker tracker = new ModifierTracker(modifier, countersNeeded);
trackerMap.put(modifier.getUniqueIdentifier(), tracker);
return tracker;
}
public static ModifierTracker getTracker(Modifier modifier)
{
return trackerMap.getOrDefault(modifier.getUniqueIdentifier(), null);
}
public static ModifierTracker getTracker(Class<? extends Modifier> clazz)
{
String name = "";
try
{
Method method = clazz.getDeclaredMethod("getUniqueIdentifier");
name = (String) method.invoke(null);
}
catch (Exception e)
{
e.printStackTrace();
}
return trackerMap.getOrDefault(name, null);
}
protected String getName()
{
return modifier.getName();
}
public String getUniqueIdentifier()
{
return BloodArsenal.MOD_ID + ".tracker." + getName();
}
public Modifier getModifier()
{
return modifier;
}
/**
* When called the ModifierTracker should reset all of its data, including
* upgrades.
*/
public void resetTracker()
{
counter = 0;
}
public void readFromNBT(NBTTagCompound tag)
{
counter = tag.getDouble(getUniqueIdentifier());
}
public void writeToNBT(NBTTagCompound tag)
{
tag.setDouble(getUniqueIdentifier(), counter);
}
public boolean onTick(IModifiable modifiable)
{
if (changeMap.containsKey(modifiable) && changeMap.get(modifiable).containsKey(modifier.getClass()))
{
double change = Math.abs(changeMap.get(modifiable).get(modifier.getClass()));
if (change > 0)
{
counter += Math.abs(changeMap.get(modifiable).get(modifier.getClass()));
HashMap<Class<? extends Modifier>, Double> lol = changeMap.get(modifiable);
lol.put(modifier.getClass(), 0D);
changeMap.put(modifiable, lol);
markDirty();
return true;
}
}
return false;
}
public Modifier getNextModifier(HashMap<String, Modifier> modifierMap)
{
Modifier modifier = Modifier.EMPTY_MODIFIER;
for (Entry<String, Modifier> entry : modifierMap.entrySet())
if (entry.getValue().getClass().isInstance(this.modifier))
modifier = entry.getValue();
if (modifier != Modifier.EMPTY_MODIFIER)
for (int i = COUNTERS_NEEDED.length - 1; i > 0; i--)
if (counter >= COUNTERS_NEEDED[i])
return modifier.getLevel() < i ? this.modifier.newCopy(i) : modifier;
return modifier;
}
/**
* Used to obtain the progress from the current level to the next level.
* <p>
* 0.0 being 0% - 1.0 being 100%.
*
* @return the progress from the current level to the next level.
*/
public double getProgress(int currentLevel)
{
return Utils.calculateStandardProgress(counter, COUNTERS_NEEDED, currentLevel);
}
public final boolean isDirty()
{
return isDirty;
}
public final void markDirty()
{
isDirty = true;
}
public final void resetDirty()
{
isDirty = false;
}
public boolean providesModifier(String key)
{
return key.equals(getUniqueIdentifier());
}
public void onModifierAdded(Modifier modifier)
{
if (modifier.getClass().isInstance(this.modifier))
{
int level = modifier.getLevel();
if (level < COUNTERS_NEEDED.length)
{
counter = Math.max(counter, COUNTERS_NEEDED[level]);
markDirty();
}
}
}
public void incrementCounter(IModifiable modifiable, double increment)
{
if (changeMap.containsKey(modifiable) && changeMap.get(modifiable).containsKey(modifier.getClass()))
{
HashMap<Class<? extends Modifier>, Double> lol = changeMap.get(modifiable);
lol.put(modifier.getClass(), changeMap.get(modifiable).get(modifier.getClass()) + increment);
changeMap.put(modifiable, lol);
}
else
{
HashMap<Class<? extends Modifier>, Double> lol = new HashMap<>();
lol.put(modifier.getClass(), increment);
changeMap.put(modifiable, lol);
}
}
public static void incrementCounter(IModifiable modifiable, Class<? extends Modifier> clazz, double increment)
{
if (changeMap.containsKey(modifiable) && changeMap.get(modifiable).containsKey(clazz))
{
HashMap<Class<? extends Modifier>, Double> lol = changeMap.get(modifiable);
lol.put(clazz, changeMap.get(modifiable).get(clazz) + increment);
changeMap.put(modifiable, lol);
}
else
{
HashMap<Class<? extends Modifier>, Double> lol = new HashMap<>();
lol.put(clazz, increment);
changeMap.put(modifiable, lol);
}
}
}
| 38,095
|
https://github.com/manfredma/exercises/blob/master/dsl/ognl/ognl.adoc
|
Github Open Source
|
Open Source
|
Apache-2.0
| 2,023
|
exercises
|
manfredma
|
AsciiDoc
|
Code
| 4
| 49
|
== 参考
[%hardbreaks]
https://zhuanlan.zhihu.com/p/434518054[强大的表达式引擎--OGNL]
| 15,712
|
https://github.com/mainthread-technology/grand-maps-for-muzei/blob/master/mobile/src/main/java/technology/mainthread/apps/grandmaps/data/ConvertPreferences.java
|
Github Open Source
|
Open Source
|
Apache-2.0
| 2,017
|
grand-maps-for-muzei
|
mainthread-technology
|
Java
|
Code
| 108
| 415
|
package technology.mainthread.apps.grandmaps.data;
import android.annotation.SuppressLint;
import android.content.SharedPreferences;
import android.content.res.Resources;
import java.util.Map;
import javax.inject.Inject;
import technology.mainthread.apps.grandmaps.R;
public class ConvertPreferences {
private static final String KEY_PREF_CHECKED = "KEY_PREF_CHECKED";
private final Resources resources;
private final SharedPreferences preferences;
@Inject
public ConvertPreferences(Resources resources, SharedPreferences preferences) {
this.resources = resources;
this.preferences = preferences;
}
public void checkAndFixPreferences() {
if (!preferences.getBoolean(KEY_PREF_CHECKED, false)) {
String keyFrequency = resources.getString(R.string.key_frequency);
@SuppressLint("CommitPrefEdits")
SharedPreferences.Editor editor = preferences.edit();
if (preferences.contains(keyFrequency)) {
Map<String, ?> keys = preferences.getAll();
for (Map.Entry<String, ?> entry : keys.entrySet()) {
if (entry.getKey().equals(keyFrequency)
&& entry.getValue().getClass().equals(Integer.class)) {
// Convert frequency preference value to string
int value = (Integer) entry.getValue();
editor.remove(keyFrequency)
.putString(keyFrequency, Integer.toString(value));
break;
}
}
}
editor.putBoolean(KEY_PREF_CHECKED, true).apply();
}
}
}
| 13,902
|
https://github.com/WanKerr/Sonic4Episode1/blob/master/Sonic4Episode1/AppMain/Gm/GmOver.cs
|
Github Open Source
|
Open Source
|
Unlicense
| 2,021
|
Sonic4Episode1
|
WanKerr
|
C#
|
Code
| 551
| 3,411
|
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Media;
using mpp;
public partial class AppMain
{
private static void GmOverBuildDataInit()
{
for (int index = 0; index < 2; ++index)
{
AppMain.gm_over_textures[index].Clear();
AppMain.gm_over_texamb_list[index] = (AppMain.AMS_AMB_HEADER)AppMain.ObjDataLoadAmbIndex((AppMain.OBS_DATA_WORK)null, AppMain.gm_over_tex_amb_idx_tbl[AppMain.GsEnvGetLanguage()][index], AppMain.GmGameDatGetCockpitData());
AppMain.AoTexBuild(AppMain.gm_over_textures[index], AppMain.gm_over_texamb_list[index]);
AppMain.AoTexLoad(AppMain.gm_over_textures[index]);
}
}
private static bool GmOverBuildDataLoop()
{
bool flag = true;
for (int index = 0; index < 2; ++index)
{
if (!AppMain.AoTexIsLoaded(AppMain.gm_over_textures[index]))
flag = false;
}
return flag;
}
private static void GmOverFlushDataInit()
{
for (int index = 0; index < 2; ++index)
AppMain.AoTexRelease(AppMain.gm_over_textures[index]);
}
private static bool GmOverFlushDataLoop()
{
bool flag = true;
for (int index = 0; index < 2; ++index)
{
if (AppMain.gm_over_texamb_list[index] != null)
{
if (!AppMain.AoTexIsReleased(AppMain.gm_over_textures[index]))
{
flag = false;
}
else
{
AppMain.gm_over_texamb_list[index] = (AppMain.AMS_AMB_HEADER)null;
AppMain.gm_over_textures[index].Clear();
}
}
}
return flag;
}
private static void GmOverStart(int type)
{
SaveState.deleteSave();
AppMain.gm_over_tcb = AppMain.MTM_TASK_MAKE_TCB(new AppMain.GSF_TASK_PROCEDURE(AppMain.gmOverMain), new AppMain.GSF_TASK_PROCEDURE(AppMain.gmOverDest), 0U, (ushort)0, 18464U, 5, (AppMain.TaskWorkFactoryDelegate)(() => (object)new AppMain.GMS_OVER_MGR_WORK()), "GM_OVER_MGR");
AppMain.GMS_OVER_MGR_WORK work1 = (AppMain.GMS_OVER_MGR_WORK)AppMain.gm_over_tcb.work;
work1.Clear();
for (int index = 0; index < 4; ++index)
{
AppMain.OBS_OBJECT_WORK work2 = AppMain.GMM_COCKPIT_CREATE_WORK((AppMain.TaskWorkFactoryDelegate)(() => (object)new AppMain.GMS_COCKPIT_2D_WORK()), (AppMain.OBS_OBJECT_WORK)null, (ushort)0, "GAME_OVER");
AppMain.GMS_COCKPIT_2D_WORK cpit_2d = (AppMain.GMS_COCKPIT_2D_WORK)work2;
AppMain.ObjObjectAction2dAMALoadSetTexlist(work2, cpit_2d.obj_2d, (AppMain.OBS_DATA_WORK)null, (string)null, AppMain.gm_over_ama_amb_idx_tbl[AppMain.GsEnvGetLanguage()][1], AppMain.GmGameDatGetCockpitData(), AppMain.AoTexGetTexList(AppMain.gm_over_textures[1]), AppMain.gm_over_string_act_id_tbl[AppMain.GsEnvGetLanguage()][index], 0);
work1.string_sub_parts[index] = cpit_2d;
AppMain.gmOverSetActionHide(cpit_2d);
}
for (int index = 0; index < 2; ++index)
{
AppMain.OBS_OBJECT_WORK work2 = AppMain.GMM_COCKPIT_CREATE_WORK((AppMain.TaskWorkFactoryDelegate)(() => (object)new AppMain.GMS_COCKPIT_2D_WORK()), (AppMain.OBS_OBJECT_WORK)null, (ushort)0, "GAME_OVER");
AppMain.GMS_COCKPIT_2D_WORK cpit_2d = (AppMain.GMS_COCKPIT_2D_WORK)work2;
AppMain.ObjObjectAction2dAMALoadSetTexlist(work2, cpit_2d.obj_2d, (AppMain.OBS_DATA_WORK)null, (string)null, AppMain.gm_over_ama_amb_idx_tbl[AppMain.GsEnvGetLanguage()][0], AppMain.GmGameDatGetCockpitData(), AppMain.AoTexGetTexList(AppMain.gm_over_textures[0]), AppMain.gm_over_fadeout_act_id_tbl[index], 0);
work1.fadeout_sub_parts[index] = cpit_2d;
work2.pos.z = -65536;
work2.disp_flag &= 4294967291U;
AppMain.gmOverSetActionHide(cpit_2d);
}
switch (type)
{
case 0:
AppMain.gmOverProcUpdateGOInit(work1);
break;
case 1:
AppMain.gmOverProcUpdateTOInit(work1);
break;
}
work1.proc_disp = new AppMain._GMS_OVER_MGR_WORK_UD_(AppMain.gmOverProcDispLoop);
}
private static void GmOverExit()
{
if (AppMain.gm_over_tcb == null)
return;
AppMain.mtTaskClearTcb(AppMain.gm_over_tcb);
AppMain.gm_over_tcb = (AppMain.MTS_TASK_TCB)null;
}
private static bool gmOverIsSkipKeyOn()
{
if ((AoPad.AoPadDirect() & ControllerConsts.CONFIRM) == 0 && !AppMain.isBackKeyPressed())
return false;
AppMain.setBackKeyRequest(false);
return true;
}
private static void gmOverSetActionHide(AppMain.GMS_COCKPIT_2D_WORK cpit_2d)
{
((AppMain.OBS_OBJECT_WORK)cpit_2d).disp_flag |= 4128U;
}
private static void gmOverSetActionPlay(AppMain.GMS_COCKPIT_2D_WORK cpit_2d)
{
((AppMain.OBS_OBJECT_WORK)cpit_2d).disp_flag &= 4294963167U;
}
private static void gmOverSetActionPause(AppMain.GMS_COCKPIT_2D_WORK cpit_2d)
{
AppMain.OBS_OBJECT_WORK obsObjectWork = (AppMain.OBS_OBJECT_WORK)cpit_2d;
obsObjectWork.disp_flag &= 4294967263U;
obsObjectWork.disp_flag |= 4096U;
}
private static void gmOverDest(AppMain.MTS_TASK_TCB tcb)
{
}
private static void gmOverMain(AppMain.MTS_TASK_TCB tcb)
{
AppMain.GMS_OVER_MGR_WORK work = (AppMain.GMS_OVER_MGR_WORK)tcb.work;
if (work.proc_update != null)
work.proc_update(work);
if (work.proc_disp == null)
return;
work.proc_disp(work);
}
private static void gmOverProcUpdateGOInit(AppMain.GMS_OVER_MGR_WORK mgr_work)
{
mgr_work.wait_timer = 30U;
mgr_work.proc_update = new AppMain._GMS_OVER_MGR_WORK_UD_(AppMain.gmOverProcUpdateGOWaitStart);
}
private static void gmOverProcUpdateGOWaitStart(AppMain.GMS_OVER_MGR_WORK mgr_work)
{
if (mgr_work.wait_timer != 0U)
{
--mgr_work.wait_timer;
}
else
{
AppMain.gmOverSetActionPlay(mgr_work.string_sub_parts[0]);
AppMain.gmOverSetActionPlay(mgr_work.string_sub_parts[1]);
mgr_work.wait_timer = 480U;
mgr_work.proc_update = new AppMain._GMS_OVER_MGR_WORK_UD_(AppMain.gmOverProcUpdateGOLoop);
}
}
private static void gmOverProcUpdateGOLoop(AppMain.GMS_OVER_MGR_WORK mgr_work)
{
if (AppMain.gmOverIsSkipKeyOn())
mgr_work.wait_timer = 0U;
if (mgr_work.wait_timer != 0U)
{
--mgr_work.wait_timer;
}
else
{
AppMain.gmOverSetActionPlay(mgr_work.fadeout_sub_parts[0]);
mgr_work.proc_update = new AppMain._GMS_OVER_MGR_WORK_UD_(AppMain.gmOverProcUpdateGOWaitFadeEnd);
}
}
private static void gmOverProcUpdateGOWaitFadeEnd(AppMain.GMS_OVER_MGR_WORK mgr_work)
{
if (((int)((AppMain.OBS_OBJECT_WORK)mgr_work.fadeout_sub_parts[0]).disp_flag & 8) == 0)
return;
AppMain.IzFadeInitEasy(0U, 1U, 1f);
mgr_work.proc_update = new AppMain._GMS_OVER_MGR_WORK_UD_(AppMain.gmOverProcUpdateGOWaitFinalizeFade);
}
private static void gmOverProcUpdateGOWaitFinalizeFade(AppMain.GMS_OVER_MGR_WORK mgr_work)
{
if (!AppMain.IzFadeIsEnd())
return;
AppMain.g_gm_main_system.game_flag |= 256U;
mgr_work.proc_update = (AppMain._GMS_OVER_MGR_WORK_UD_)null;
}
private static void gmOverProcUpdateTOInit(AppMain.GMS_OVER_MGR_WORK mgr_work)
{
mgr_work.wait_timer = 30U;
mgr_work.proc_update = new AppMain._GMS_OVER_MGR_WORK_UD_(AppMain.gmOverProcUpdateTOWaitStart);
}
private static void gmOverProcUpdateTOWaitStart(AppMain.GMS_OVER_MGR_WORK mgr_work)
{
if (mgr_work.wait_timer != 0U)
{
--mgr_work.wait_timer;
}
else
{
AppMain.gmOverSetActionPlay(mgr_work.string_sub_parts[2]);
AppMain.gmOverSetActionPlay(mgr_work.string_sub_parts[3]);
AppMain.gmOverSetActionPlay(mgr_work.fadeout_sub_parts[1]);
mgr_work.proc_update = new AppMain._GMS_OVER_MGR_WORK_UD_(AppMain.gmOverProcUpdateTOWaitFadeEnd);
}
}
private static void gmOverProcUpdateTOWaitFadeEnd(AppMain.GMS_OVER_MGR_WORK mgr_work)
{
if (((int)((AppMain.OBS_OBJECT_WORK)mgr_work.fadeout_sub_parts[1]).disp_flag & 8) == 0)
return;
AppMain.IzFadeInitEasy(0U, 1U, 1f);
mgr_work.proc_update = new AppMain._GMS_OVER_MGR_WORK_UD_(AppMain.gmOverProcUpdateTOWaitFinalizeFade);
}
private static void gmOverProcUpdateTOWaitFinalizeFade(AppMain.GMS_OVER_MGR_WORK mgr_work)
{
if (!AppMain.IzFadeIsEnd())
return;
AppMain.g_gm_main_system.game_flag |= 256U;
mgr_work.proc_update = (AppMain._GMS_OVER_MGR_WORK_UD_)null;
}
private static void gmOverProcDispLoop(AppMain.GMS_OVER_MGR_WORK mgr_work)
{
}
}
| 38,853
|
https://github.com/dayvidwhy/response-radar/blob/master/app/server.rb
|
Github Open Source
|
Open Source
|
MIT
| 2,021
|
response-radar
|
dayvidwhy
|
Ruby
|
Code
| 344
| 883
|
# frozen_string_literal: true
# library imports
require 'sinatra/base'
require 'json'
require 'securerandom'
# load our radar
require_relative './radar'
require_relative '../utils/validate'
# Helper to setup our routes on the server and then
# provides a method to actually start the server.
class Server < Sinatra::Base
set :radars, {}
helpers do
def radars
self.class.radars
end
end
configure do
# sinatra traps system interupts
# turning this off helps us stop the server
# if one of our checking loops is still running
disable :traps
end
# simple endpoint that receives a url and request type to check
post '/create' do
data = JSON.parse(request.body.read)
if !data.key?('url') || !data.key?('hook')
# return our response
body(JSON.generate({
'status' => 'Parameters not sent'
}))
halt 200
end
if !valid_url(data['url']) || !valid_url(data['hook'])
# return our response
body(JSON.generate({
'status' => 'URLs are not valid'
}))
halt 200
end
# create and start our radar
radar = ResponseRadar.new(data['url'], data['hook'])
radar.start
# store a reference
radar_id = SecureRandom.uuid
radars[radar_id] = radar
# return our response
body(JSON.generate({
'status' => 'Okay',
'id' => radar_id
}))
status 200
end
# stops a certain radar based on an ID
post '/change/:action' do
data = JSON.parse(request.body.read)
if params['action'] != 'start' && params['action'] != 'stop'
body(JSON.generate({
'status' => 'Action not possible'
}))
halt 200
end
# did we receive an id?
unless data.key?('id')
body(JSON.generate({
'status' => 'ID not sent'
}))
halt 200
end
radar_id = data['id']
# was the id related to a radar?
unless radars.key?(radar_id)
body(JSON.generate({
'status' => 'ID was not valid'
}))
halt 200
end
# perform the request action
result = false
case params['action']
when 'stop'
result = radars[radar_id].stop
when 'start'
result = radars[radar_id].start
end
# check status of the action
response_status = ''
if result
response_status = 'Radar adjusted'
else
response_status = 'Radar was already adjusted'
end
# return our status
body(JSON.generate({
'status' => response_status
}))
status 200
end
# endpoint for testing
get '/notify' do
puts 'Was notified of being down'
status 200
end
begin
run!
rescue Interrupt
quit!
radars.each do |_radar_id, radar|
radar.stop
end
warn 'Process interrupted, shutting down.'
rescue StandardError
warn 'Other exception.'
end
end
| 17,055
|
https://github.com/mathinking/HopfieldNetworkToolbox/blob/master/help_source/chn_users_guide.m
|
Github Open Source
|
Open Source
|
BSD-2-Clause
| 2,021
|
HopfieldNetworkToolbox
|
mathinking
|
MATLAB
|
Code
| 129
| 296
|
%% Hopfield Network Toolbox User's Guide
% The following examples can be used as a user's guide to get yourself familiar
% with the |HopfieldNetworkGQKP| and |HopfieldNetworkTSP| classes and additional
% functions.
%
% * <chn_users_guide_hopfieldnet.html What is HopfieldNetwork?>
% * <chn_users_guide_howToUseTsphopfieldnetOptions.html How to use tsphopfieldnet and tsphopfieldnetOptions>
% * <chn_users_guide_TSP.html How to solve the Traveling Salesman Problem using Hopfield Networks>
% * <chn_users_guide_improve.html How to solve improve the performance of the Hopfield Network for the TSP>
% * <chn_users_guide_improveHybrid.html How to solve improve the performance of the Hopfield Network for the TSP using Hybrid methods>
% * <chn_users_guide_howToUsehopfieldnetOptions.html How to use hopfieldnet and hopfieldnetOptions>
% * <Example_GQKPusingCHN.html How to solve a GQKP problem using a Hopfield Network>
% * <chn_users_guide_SimulinkModels.html How to solve Hopfield Networks using Simulink>
%
| 33,088
|
https://github.com/mikolajs/libgdx-demo/blob/master/desktop/src/main/scala/Main.scala
|
Github Open Source
|
Open Source
|
MIT
| null |
libgdx-demo
|
mikolajs
|
Scala
|
Code
| 34
| 106
|
package pl.edu.osp
import com.badlogic.gdx.backends.lwjgl._
object Main extends App {
val cfg = new LwjglApplicationConfiguration
cfg.title = "libgdx-demo"
cfg.height = 700
cfg.width = 1200
cfg.forceExit = false
cfg.useGL30 = true
new LwjglApplication(new Libgdxdemo, cfg)
}
| 18,755
|
https://github.com/TheGenuine/commutie/blob/master/app/src/main/java/de/reneruck/traincheck/MainActivity.java
|
Github Open Source
|
Open Source
|
MIT
| null |
commutie
|
TheGenuine
|
Java
|
Code
| 227
| 1,089
|
package de.reneruck.traincheck;
import android.app.Activity;
import android.app.TimePickerDialog;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.Switch;
import android.widget.TimePicker;
import android.widget.Toast;
import com.dexafree.materialList.card.Card;
import com.dexafree.materialList.card.provider.BasicImageButtonsCardProvider;
import com.dexafree.materialList.view.MaterialListView;
import java.util.ArrayList;
import java.util.List;
import de.reneruck.traincheck.models.Tracker;
import de.reneruck.traincheck.models.TrackerCardProvider;
import de.reneruck.traincheck.receivers.UpdateTrackingReceiver;
public class MainActivity extends Activity {
private SharedPreferences mPreferences;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mPreferences = getPreferences(Context.MODE_PRIVATE);
List<Tracker> trackers = loadTrackers();
initializeList(trackers);
}
private void initializeList(List<Tracker> trackers) {
MaterialListView mListView = (MaterialListView) findViewById(R.id.material_listview);
for(Tracker tracker : trackers){
Card card = new Card.Builder(this)
.setTag(tracker.getTrackerId())
.withProvider(TrackerCardProvider.class)
.setStartTime(tracker.getStartTrackingAt())
.setEndTime(tracker.getStopTrackingAt())
.setPrimaryStation(tracker.getPrimaryStation())
.setPrimaryDirection(tracker.getDirectionPrimary())
.setEnabled(tracker.isEnabled())
.setOnCheckChangedListener(trackerEnableListener)
.setCardClickListener(cardClickListener)
.endConfig()
.build();
mListView.add(card);
}
}
private List<Tracker> loadTrackers() {
return Tracker.find(this, null);
}
private CompoundButton.OnCheckedChangeListener trackerEnableListener = new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
Toast.makeText(buttonView.getContext(), "Tracker enabled " + isChecked, Toast.LENGTH_LONG).show();
}
};
private View.OnClickListener cardClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
int id = Integer.valueOf(((View)v.getParent()).getTag().toString());
Intent intent = new Intent(getApplicationContext(), EditTrackerActivity.class);
intent.getExtras().putInt("trackerId", id);
startActivityForResult(intent, id);
}
};
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()){
case R.id.action_settings:
return true;
case R.id.action_add_tracker:
startActivity(new Intent(getApplicationContext(), EditTrackerActivity.class));
return true;
case R.id.action_send_test_broadcast:
Intent serviceIntent = new Intent(getApplicationContext(), UpdateTrackingReceiver.class);
sendBroadcast(serviceIntent);
return true;
}
return super.onOptionsItemSelected(item);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
((MaterialListView)findViewById(R.id.material_listview)).invalidate();
}
}
| 22,073
|
https://github.com/Iceberry-qdd/Leetcode-practice/blob/master/Java/L54.java
|
Github Open Source
|
Open Source
|
MIT
| null |
Leetcode-practice
|
Iceberry-qdd
|
Java
|
Code
| 272
| 738
|
import java.util.ArrayList;
import java.util.List;
public class L54 {
public static void main(String[] args) {
//int[][] matrix={{1,2,3,4},{5,6,7,8},{9,10,11,12}};
System.out.println(spiralOrder(new int[][]{{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}}));
System.out.println(spiralOrder(new int[][]{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}));
System.out.println(spiralOrder(new int[][]{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}, {10, 11, 12}}));
System.out.println(spiralOrder(new int[][]{{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}, {13, 14, 15, 16}}));
System.out.println(spiralOrder(new int[][]{{1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}, {16, 17, 18, 19, 20}, {21, 22, 23, 24, 25}}));
System.out.println(spiralOrder(new int[][]{{0}, {1}}));
}
public static List<Integer> spiralOrder(int[][] matrix) {
int lenColumn = matrix[0].length, lenRow = matrix.length;
List<Integer> result = new ArrayList<>(lenColumn * lenRow);
int top = 0, right = 0, bottom = 0, left = 0;
int laps = 0, count = lenColumn * lenRow;
while (count > 0) {
while (top < lenColumn - 1 - laps && count > 0) {
result.add(matrix[laps][top]);
top++;
count--;
}
while (right < lenRow - 1 - laps && count > 0) {
result.add(matrix[right][lenColumn - 1 - laps]);
right++;
count--;
}
while (bottom < lenColumn - 1 - laps && count > 0) {
result.add(matrix[lenRow - 1 - laps][lenColumn - 1 - bottom]);
bottom++;
count--;
}
while (left < lenRow - 1 - laps && count > 0) {
result.add(matrix[lenRow - 1 - left][laps]);
left++;
count--;
}
if (lenRow == lenColumn && (lenColumn * lenRow) % 2 != 0 && result.size() == lenColumn * lenRow - 1) {
result.add(matrix[lenRow >> 1][lenColumn >> 1]);
break;
}
top = bottom = left = right = ++laps;
}
return result;
}
}
| 16,733
|
https://github.com/mfkiwl/spu32/blob/master/software/asm/spi-test.s
|
Github Open Source
|
Open Source
|
MIT
| 2,022
|
spu32
|
mfkiwl
|
GAS
|
Code
| 148
| 444
|
#include "devices.h"
.section .text
.global _start
#define SPI_OP_READ 0x03
main:
jal chipdeselect
jal chipselect
# send read opcode
li a0, SPI_OP_READ
jal transmit
# write three address bytes
li a0, 0
jal transmit
li a0, 0
jal transmit
li a0, 0
jal transmit
li t1, 0
main_readloop:
li a0, 0
jal transmit
# push read value to LEDs
sb a0, DEV_LED(zero)
# delay
li a0, 16384
main_delay:
addi a0, a0, -1
bnez a0, main_delay
j main_readloop
chipselect:
li a6, 1
sb a6, DEV_SPI_SELECT(zero)
ret
chipdeselect:
sb zero, DEV_SPI_SELECT(zero)
ret
transmit:
# wait until SPI port is ready
transmit_readyloop:
lbu a6, DEV_SPI_READY(zero)
beqz a6, transmit_readyloop
# start transmission by writing data to SPI port
sb a0, DEV_SPI_DATA(zero)
# wait until SPI port is ready again (transmission finished)
transmit_readyloop2:
lbu a6, DEV_SPI_READY(zero)
beqz a6, transmit_readyloop2
# write received data to a0 and return
lbu a0, DEV_SPI_DATA(zero)
ret
.size main, .-main
| 41,935
|
https://github.com/sphereio/commercetools-php-raml/blob/master/lib/commercetools-api/src/Models/ProductSelection/ProductSelectionCollection.php
|
Github Open Source
|
Open Source
|
MIT
| null |
commercetools-php-raml
|
sphereio
|
PHP
|
Code
| 119
| 360
|
<?php
declare(strict_types=1);
/**
* This file has been auto generated
* Do not change it.
*/
namespace Commercetools\Api\Models\ProductSelection;
use Commercetools\Api\Models\Common\BaseResourceCollection;
use Commercetools\Exception\InvalidArgumentException;
use stdClass;
/**
* @extends BaseResourceCollection<ProductSelection>
* @method ProductSelection current()
* @method ProductSelection end()
* @method ProductSelection at($offset)
*/
class ProductSelectionCollection extends BaseResourceCollection
{
/**
* @psalm-assert ProductSelection $value
* @psalm-param ProductSelection|stdClass $value
* @throws InvalidArgumentException
*
* @return ProductSelectionCollection
*/
public function add($value)
{
if (!$value instanceof ProductSelection) {
throw new InvalidArgumentException();
}
$this->store($value);
return $this;
}
/**
* @psalm-return callable(int):?ProductSelection
*/
protected function mapper()
{
return function (?int $index): ?ProductSelection {
$data = $this->get($index);
if ($data instanceof stdClass) {
/** @var ProductSelection $data */
$data = ProductSelectionModel::of($data);
$this->set($data, $index);
}
return $data;
};
}
}
| 40,936
|
https://github.com/kristijankoscak/NWP-LV5/blob/master/resources/lang/en/task-messages.php
|
Github Open Source
|
Open Source
|
MIT
| null |
NWP-LV5
|
kristijankoscak
|
PHP
|
Code
| 35
| 111
|
<?php
return [
'name'=> 'Task name (on Croatian)',
'name_en'=> 'Task name',
'study_type' => 'Study type',
'assignment' => 'Assignment',
'add_button' => 'Add task',
'undergraduate_study' => 'Undergraduate Study',
'graduate_study' => 'Graduate Study',
'professional_study' => 'Professional Study'
];
| 30,538
|
https://github.com/ConanODoyle/io_scene_dts/blob/master/import_dts.py
|
Github Open Source
|
Open Source
|
MIT
| 2,021
|
io_scene_dts
|
ConanODoyle
|
Python
|
Code
| 1,475
| 5,496
|
import bpy
import os
from bpy_extras.io_utils import unpack_list
from .DtsShape import DtsShape
from .DtsTypes import *
from .write_report import write_debug_report
from .util import default_materials, resolve_texture, get_rgb_colors, fail, \
ob_location_curves, ob_scale_curves, ob_rotation_curves, ob_rotation_data, evaluate_all
import operator
from itertools import zip_longest, count
from functools import reduce
from random import random
def grouper(iterable, n, fillvalue=None):
"Collect data into fixed-length chunks or blocks"
# grouper('ABCDEFG', 3, 'x') --> ABC DEF Gxx"
args = [iter(iterable)] * n
return zip_longest(*args, fillvalue=fillvalue)
def dedup_name(group, name):
if name not in group:
return name
for suffix in count(2):
new_name = name + "#" + str(suffix)
if new_name not in group:
return new_name
def import_material(color_source, dmat, filepath):
bmat = bpy.data.materials.new(dedup_name(bpy.data.materials, dmat.name))
bmat.diffuse_intensity = 1
texname = resolve_texture(filepath, dmat.name)
if texname is not None:
try:
teximg = bpy.data.images.load(texname)
except:
print("Cannot load image", texname)
texslot = bmat.texture_slots.add()
texslot.use_map_alpha = True
tex = texslot.texture = bpy.data.textures.new(dmat.name, "IMAGE")
tex.image = teximg
# Try to figure out a diffuse color for solid shading
if teximg.size[0] <= 16 and teximg.size[1] <= 16:
if teximg.use_alpha:
pixels = grouper(teximg.pixels, 4)
else:
pixels = grouper(teximg.pixels, 3)
color = pixels.__next__()
for other in pixels:
if other != color:
break
else:
bmat.diffuse_color = color[:3]
elif dmat.name.lower() in default_materials:
bmat.diffuse_color = default_materials[dmat.name.lower()]
else: # give it a random color
bmat.diffuse_color = color_source.__next__()
if dmat.flags & Material.SelfIlluminating:
bmat.use_shadeless = True
if dmat.flags & Material.Translucent:
bmat.use_transparency = True
if dmat.flags & Material.Additive:
bmat.torque_props.blend_mode = "ADDITIVE"
elif dmat.flags & Material.Subtractive:
bmat.torque_props.blend_mode = "SUBTRACTIVE"
else:
bmat.torque_props.blend_mode = "NONE"
if dmat.flags & Material.SWrap:
bmat.torque_props.s_wrap = True
if dmat.flags & Material.TWrap:
bmat.torque_props.t_wraps = True
if dmat.flags & Material.IFLMaterial:
bmat.torque_props.use_ifl = True
# TODO: MipMapZeroBorder, IFLFrame, DetailMap, BumpMap, ReflectanceMap
# AuxilaryMask?
return bmat
class index_pass:
def __getitem__(self, item):
return item
def create_bmesh(dmesh, materials, shape):
me = bpy.data.meshes.new("Mesh")
faces = []
material_indices = {}
indices_pass = index_pass()
for prim in dmesh.primitives:
if prim.type & Primitive.Indexed:
indices = dmesh.indices
else:
indices = indices_pass
dmat = None
if not (prim.type & Primitive.NoMaterial):
dmat = shape.materials[prim.type & Primitive.MaterialMask]
if dmat not in material_indices:
material_indices[dmat] = len(me.materials)
me.materials.append(materials[dmat])
if prim.type & Primitive.Strip:
even = True
for i in range(prim.firstElement + 2, prim.firstElement + prim.numElements):
if even:
faces.append(((indices[i], indices[i - 1], indices[i - 2]), dmat))
else:
faces.append(((indices[i - 2], indices[i - 1], indices[i]), dmat))
even = not even
elif prim.type & Primitive.Fan:
even = True
for i in range(prim.firstElement + 2, prim.firstElement + prim.numElements):
if even:
faces.append(((indices[i], indices[i - 1], indices[0]), dmat))
else:
faces.append(((indices[0], indices[i - 1], indices[i]), dmat))
even = not even
else: # Default to Triangle Lists (prim.type & Primitive.Triangles)
for i in range(prim.firstElement + 2, prim.firstElement + prim.numElements, 3):
faces.append(((indices[i], indices[i - 1], indices[i - 2]), dmat))
me.vertices.add(len(dmesh.verts))
me.vertices.foreach_set("co", unpack_list(dmesh.verts))
me.vertices.foreach_set("normal", unpack_list(dmesh.normals))
me.polygons.add(len(faces))
me.loops.add(len(faces) * 3)
me.uv_textures.new()
uvs = me.uv_layers[0]
for i, ((verts, dmat), poly) in enumerate(zip(faces, me.polygons)):
poly.use_smooth = True # DTS geometry is always smooth shaded
poly.loop_total = 3
poly.loop_start = i * 3
if dmat:
poly.material_index = material_indices[dmat]
for j, index in zip(poly.loop_indices, verts):
me.loops[j].vertex_index = index
uv = dmesh.tverts[index]
uvs.data[j].uv = (uv.x, 1 - uv.y)
me.validate()
me.update()
return me
def file_base_name(filepath):
return os.path.basename(filepath).rsplit(".", 1)[0]
def insert_reference(frame, shape_nodes):
for node in shape_nodes:
ob = node.bl_ob
curves = ob_location_curves(ob)
for curve in curves:
curve.keyframe_points.add(1)
key = curve.keyframe_points[-1]
key.interpolation = "LINEAR"
key.co = (frame, ob.location[curve.array_index])
curves = ob_scale_curves(ob)
for curve in curves:
curve.keyframe_points.add(1)
key = curve.keyframe_points[-1]
key.interpolation = "LINEAR"
key.co = (frame, ob.scale[curve.array_index])
_, curves = ob_rotation_curves(ob)
rot = ob_rotation_data(ob)
for curve in curves:
curve.keyframe_points.add(1)
key = curve.keyframe_points[-1]
key.interpolation = "LINEAR"
key.co = (frame, rot[curve.array_index])
def load(operator, context, filepath,
reference_keyframe=True,
import_sequences=True,
use_armature=False,
debug_report=False):
shape = DtsShape()
with open(filepath, "rb") as fd:
shape.load(fd)
if debug_report:
write_debug_report(filepath + ".txt", shape)
with open(filepath + ".pass.dts", "wb") as fd:
shape.save(fd)
# Create a Blender material for each DTS material
materials = {}
color_source = get_rgb_colors()
for dmat in shape.materials:
materials[dmat] = import_material(color_source, dmat, filepath)
# Now assign IFL material properties where needed
for ifl in shape.iflmaterials:
mat = materials[shape.materials[ifl.slot]]
assert mat.torque_props.use_ifl == True
mat.torque_props.ifl_name = shape.names[ifl.name]
# First load all the nodes into armatures
lod_by_mesh = {}
for lod in shape.detail_levels:
lod_by_mesh[lod.objectDetail] = lod
node_obs = []
node_obs_val = {}
if use_armature:
root_arm = bpy.data.armatures.new(file_base_name(filepath))
root_ob = bpy.data.objects.new(root_arm.name, root_arm)
root_ob.show_x_ray = True
context.scene.objects.link(root_ob)
context.scene.objects.active = root_ob
# Calculate armature-space matrix, head and tail for each node
for i, node in enumerate(shape.nodes):
node.mat = shape.default_rotations[i].to_matrix()
node.mat = Matrix.Translation(shape.default_translations[i]) * node.mat.to_4x4()
if node.parent != -1:
node.mat = shape.nodes[node.parent].mat * node.mat
# node.head = node.mat.to_translation()
# node.tail = node.head + Vector((0, 0, 0.25))
# node.tail = node.mat.to_translation()
# node.head = node.tail - Vector((0, 0, 0.25))
bpy.ops.object.mode_set(mode="EDIT")
edit_bone_table = []
bone_names = []
for i, node in enumerate(shape.nodes):
bone = root_arm.edit_bones.new(shape.names[node.name])
# bone.use_connect = True
# bone.head = node.head
# bone.tail = node.tail
bone.head = (0, 0, -0.25)
bone.tail = (0, 0, 0)
if node.parent != -1:
bone.parent = edit_bone_table[node.parent]
bone.matrix = node.mat
bone["nodeIndex"] = i
edit_bone_table.append(bone)
bone_names.append(bone.name)
bpy.ops.object.mode_set(mode="OBJECT")
else:
if reference_keyframe:
reference_marker = context.scene.timeline_markers.get("reference")
if reference_marker is None:
reference_frame = 0
context.scene.timeline_markers.new("reference", reference_frame)
else:
reference_frame = reference_marker.frame
else:
reference_frame = None
# Create an empty for every node
for i, node in enumerate(shape.nodes):
ob = bpy.data.objects.new(dedup_name(bpy.data.objects, shape.names[node.name]), None)
node.bl_ob = ob
ob["nodeIndex"] = i
ob.empty_draw_type = "SINGLE_ARROW"
ob.empty_draw_size = 0.5
if node.parent != -1:
ob.parent = node_obs[node.parent]
ob.location = shape.default_translations[i]
ob.rotation_mode = "QUATERNION"
ob.rotation_quaternion = shape.default_rotations[i]
if shape.names[node.name] == "__auto_root__" and ob.rotation_quaternion.magnitude == 0:
ob.rotation_quaternion = (1, 0, 0, 0)
context.scene.objects.link(ob)
node_obs.append(ob)
node_obs_val[node] = ob
if reference_keyframe:
insert_reference(reference_frame, shape.nodes)
# Try animation?
if import_sequences:
globalToolIndex = 10
fps = context.scene.render.fps
sequences_text = []
for seq in shape.sequences:
name = shape.names[seq.nameIndex]
print("Importing sequence", name)
flags = []
flags.append("priority {}".format(seq.priority))
if seq.flags & Sequence.Cyclic:
flags.append("cyclic")
if seq.flags & Sequence.Blend:
flags.append("blend")
flags.append("duration {}".format(seq.duration))
if flags:
sequences_text.append(name + ": " + ", ".join(flags))
nodesRotation = tuple(map(lambda p: p[0], filter(lambda p: p[1], zip(shape.nodes, seq.rotationMatters))))
nodesTranslation = tuple(map(lambda p: p[0], filter(lambda p: p[1], zip(shape.nodes, seq.translationMatters))))
nodesScale = tuple(map(lambda p: p[0], filter(lambda p: p[1], zip(shape.nodes, seq.scaleMatters))))
step = 1
for mattersIndex, node in enumerate(nodesTranslation):
ob = node_obs_val[node]
curves = ob_location_curves(ob)
for frameIndex in range(seq.numKeyframes):
vec = shape.node_translations[seq.baseTranslation + mattersIndex * seq.numKeyframes + frameIndex]
if seq.flags & Sequence.Blend:
if reference_frame is None:
return fail(operator, "Missing 'reference' marker for blend animation '{}'".format(name))
ref_vec = Vector(evaluate_all(curves, reference_frame))
vec = ref_vec + vec
for curve in curves:
curve.keyframe_points.add(1)
key = curve.keyframe_points[-1]
key.interpolation = "LINEAR"
key.co = (
globalToolIndex + frameIndex * step,
vec[curve.array_index])
for mattersIndex, node in enumerate(nodesRotation):
ob = node_obs_val[node]
mode, curves = ob_rotation_curves(ob)
for frameIndex in range(seq.numKeyframes):
rot = shape.node_rotations[seq.baseRotation + mattersIndex * seq.numKeyframes + frameIndex]
if seq.flags & Sequence.Blend:
if reference_frame is None:
return fail(operator, "Missing 'reference' marker for blend animation '{}'".format(name))
ref_rot = Quaternion(evaluate_all(curves, reference_frame))
rot = ref_rot * rot
if mode == 'AXIS_ANGLE':
rot = rot.to_axis_angle()
elif mode != 'QUATERNION':
rot = rot.to_euler(mode)
for curve in curves:
curve.keyframe_points.add(1)
key = curve.keyframe_points[-1]
key.interpolation = "LINEAR"
key.co = (
globalToolIndex + frameIndex * step,
rot[curve.array_index])
for mattersIndex, node in enumerate(nodesScale):
ob = node_obs_val[node]
curves = ob_scale_curves(ob)
for frameIndex in range(seq.numKeyframes):
index = seq.baseScale + mattersIndex * seq.numKeyframes + frameIndex
vec = shape.node_translations[seq.baseTranslation + mattersIndex * seq.numKeyframes + frameIndex]
if seq.flags & Sequence.UniformScale:
s = shape.node_uniform_scales[index]
vec = (s, s, s)
elif seq.flags & Sequence.AlignedScale:
vec = shape.node_aligned_scales[index]
elif seq.flags & Sequence.ArbitraryScale:
print("Warning: Arbitrary scale animation not implemented")
break
else:
print("Warning: Invalid scale flags found in sequence")
break
for curve in curves:
curve.keyframe_points.add(1)
key = curve.keyframe_points[-1]
key.interpolation = "LINEAR"
key.co = (
globalToolIndex + frameIndex * step,
vec[curve.array_index])
# Insert a reference frame immediately before the animation
# insert_reference(globalToolIndex - 2, shape.nodes)
context.scene.timeline_markers.new(name + ":start", globalToolIndex)
context.scene.timeline_markers.new(name + ":end", globalToolIndex + seq.numKeyframes * step - 1)
globalToolIndex += seq.numKeyframes * step + 30
if "Sequences" in bpy.data.texts:
sequences_buf = bpy.data.texts["Sequences"]
else:
sequences_buf = bpy.data.texts.new("Sequences")
sequences_buf.from_string("\n".join(sequences_text))
# Then put objects in the armatures
for obj in shape.objects:
if obj.node == -1:
print('Warning: Object {} is not attached to a node, ignoring'
.format(shape.names[obj.name]))
continue
for meshIndex in range(obj.numMeshes):
mesh = shape.meshes[obj.firstMesh + meshIndex]
mtype = mesh.type
if mtype == Mesh.NullType:
continue
if mtype != Mesh.StandardType and mtype != Mesh.SkinType:
print('Warning: Mesh #{} of object {} is of unsupported type {}, ignoring'.format(
meshIndex + 1, mtype, shape.names[obj.name]))
continue
bmesh = create_bmesh(mesh, materials, shape)
bobj = bpy.data.objects.new(dedup_name(bpy.data.objects, shape.names[obj.name]), bmesh)
context.scene.objects.link(bobj)
add_vertex_groups(mesh, bobj, shape)
if use_armature:
bobj.parent = root_ob
bobj.parent_bone = bone_names[obj.node]
bobj.parent_type = "BONE"
bobj.matrix_world = shape.nodes[obj.node].mat
if mtype == Mesh.SkinType:
modifier = bobj.modifiers.new('Armature', 'ARMATURE')
modifier.object = root_ob
else:
bobj.parent = node_obs[obj.node]
lod_name = shape.names[lod_by_mesh[meshIndex].name]
if lod_name not in bpy.data.groups:
bpy.data.groups.new(lod_name)
bpy.data.groups[lod_name].objects.link(bobj)
# Import a bounds mesh
me = bpy.data.meshes.new("Mesh")
me.vertices.add(8)
me.vertices[0].co = (shape.bounds.min.x, shape.bounds.min.y, shape.bounds.min.z)
me.vertices[1].co = (shape.bounds.max.x, shape.bounds.min.y, shape.bounds.min.z)
me.vertices[2].co = (shape.bounds.max.x, shape.bounds.max.y, shape.bounds.min.z)
me.vertices[3].co = (shape.bounds.min.x, shape.bounds.max.y, shape.bounds.min.z)
me.vertices[4].co = (shape.bounds.min.x, shape.bounds.min.y, shape.bounds.max.z)
me.vertices[5].co = (shape.bounds.max.x, shape.bounds.min.y, shape.bounds.max.z)
me.vertices[6].co = (shape.bounds.max.x, shape.bounds.max.y, shape.bounds.max.z)
me.vertices[7].co = (shape.bounds.min.x, shape.bounds.max.y, shape.bounds.max.z)
me.validate()
me.update()
ob = bpy.data.objects.new("bounds", me)
ob.draw_type = "BOUNDS"
context.scene.objects.link(ob)
return {"FINISHED"}
def add_vertex_groups(mesh, ob, shape):
for node, initial_transform in mesh.bones:
# TODO: Handle initial_transform
ob.vertex_groups.new(shape.names[shape.nodes[node].name])
for vertex, bone, weight in mesh.influences:
ob.vertex_groups[bone].add((vertex,), weight, 'REPLACE')
| 50,873
|
https://github.com/Sogrey/SogreyWeibo/blob/master/src/com/sogrey/sinaweibo/utils/InputStreamUtil.java
|
Github Open Source
|
Open Source
|
Apache-2.0
| null |
SogreyWeibo
|
Sogrey
|
Java
|
Code
| 1,954
| 7,252
|
/**
* @author Sogrey
* @date 2015年4月29日
*/
package com.sogrey.sinaweibo.utils;
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Bitmap.CompressFormat;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.PixelFormat;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.os.Environment;
import android.text.TextUtils;
import android.util.Base64;
import android.util.Log;
import android.view.Display;
import android.view.View;
/**
* @author Sogrey
* @date 2015年4月29日
*/
public class InputStreamUtil {
/**
* 1.InputStream to String
*
* @author Sogrey
*
* @date 2015年4月29日
*/
public static String inputStream2String(InputStream is) {
return inputStream2String(is, null);
}
/**
* InputStream to String
*
* @author Sogrey
* @date 2015-8-19 下午2:19:56
* @param is
* InputStream
* @param charsetName
* @return
*/
public static String inputStream2String(InputStream is, String charsetName) {
BufferedReader reader;
StringBuilder sb = new StringBuilder();
try {
InputStreamReader isr = null;
if (TextUtils.isEmpty(charsetName)) {
isr = new InputStreamReader(is);
} else {
isr = new InputStreamReader(is, charsetName);
}
reader = new BufferedReader(isr);
String line = null;
try {
while ((line = reader.readLine()) != null) {
sb.append(line);
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (null != is)
is.close();
} catch (IOException e) {
e.printStackTrace();
}
}
} catch (UnsupportedEncodingException e1) {
e1.printStackTrace();
}
return sb.toString();
}
/**
* 2.InputStream to String
*
* @author Sogrey
* @date 2015年5月20日
* @param inputStream
* @return String
*/
public static String readTextFile(InputStream inputStream) {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
byte buf[] = new byte[1024];
int len;
try {
while ((len = inputStream.read(buf)) != -1) {
outputStream.write(buf, 0, len);
}
return outputStream.toString();
} catch (IOException e) {
} finally {
if (null != outputStream) {
try {
outputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
if (null != inputStream) {
try {
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return outputStream.toString();
}
/**
* 3.Bitmap to InputStream
*
* @author Sogrey
* @date 2015年5月20日
* @param bm
* @return
*/
public static InputStream Bitmap2IS(Bitmap bm) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bm.compress(Bitmap.CompressFormat.JPEG, 100, baos);
InputStream sbs = new ByteArrayInputStream(baos.toByteArray());
return sbs;
}
/**
* 4.将byte[]转换成InputStream
*
* @author Sogrey
* @date 2015年5月20日
* @param b
* @return
*/
public static InputStream Byte2InputStream(byte[] b) {
ByteArrayInputStream bais = new ByteArrayInputStream(b);
return bais;
}
/**
* 5.将InputStream转换成byte[]
*
* @author Sogrey
* @date 2015年5月20日
* @param is
* @return
*/
public static byte[] InputStream2Bytes(InputStream is) {
String str = "";
byte[] readByte = new byte[1024];
int readCount = -1;
try {
while ((readCount = is.read(readByte, 0, 1024)) != -1) {
str += new String(readByte).trim();
}
return str.getBytes();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
/**
* 6.将Bitmap转换成InputStream
*
* @author Sogrey
* @date 2015年5月20日
* @param bm
* @return
*/
public static InputStream Bitmap2InputStream(Bitmap bm) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bm.compress(Bitmap.CompressFormat.JPEG, 100, baos);
InputStream is = new ByteArrayInputStream(baos.toByteArray());
return is;
}
/**
* 7.将Bitmap转换成InputStream
*
* @author Sogrey
* @date 2015年5月20日
* @param bm
* @param quality
* @return
*/
public static InputStream Bitmap2InputStream(Bitmap bm, int quality) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bm.compress(Bitmap.CompressFormat.PNG, quality, baos);
InputStream is = new ByteArrayInputStream(baos.toByteArray());
return is;
}
/**
* 8.将InputStream转换成Bitmap
*
* @author Sogrey
* @date 2015年5月20日
* @param is
* @return
*/
public static Bitmap InputStream2Bitmap(InputStream is) {
return BitmapFactory.decodeStream(is);
}
/**
* 9.Drawable转换成InputStream
*
* @author Sogrey
* @date 2015年5月20日
* @param d
* @return
*/
public static InputStream Drawable2InputStream(Drawable d) {
Bitmap bitmap = drawable2Bitmap(d);
return Bitmap2InputStream(bitmap);
}
/**
* 10.InputStream转换成Drawable
*
* @author Sogrey
* @date 2015年5月20日
* @param is
* @return
*/
public static Drawable InputStream2Drawable(InputStream is) {
Bitmap bitmap = InputStream2Bitmap(is);
return bitmap2Drawable(bitmap);
}
/**
* 11.Drawable转换成byte[]
*
* @author Sogrey
* @date 2015年5月20日
* @param d
* @return
*/
public static byte[] Drawable2Bytes(Drawable d) {
Bitmap bitmap = drawable2Bitmap(d);
return Bitmap2Bytes(bitmap);
}
/**
* 12.byte[]转换成Drawable
*
* @author Sogrey
* @date 2015年5月20日
* @param b
* @return
*/
public static Drawable Bytes2Drawable(byte[] b) {
Bitmap bitmap = Bytes2Bitmap(b);
return bitmap2Drawable(bitmap);
}
/**
* 13.Bitmap转换成byte[]
*
* @author Sogrey
* @date 2015年5月20日
* @param bm
* @return
*/
public static byte[] Bitmap2Bytes(Bitmap bm) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
bm.compress(Bitmap.CompressFormat.PNG, 100, baos);
return baos.toByteArray();
}
/**
* 14.byte[]转换成Bitmap
*
* @author Sogrey
* @date 2015年5月20日
* @param b
* @return
*/
public static Bitmap Bytes2Bitmap(byte[] b) {
if (b.length != 0) {
return BitmapFactory.decodeByteArray(b, 0, b.length);
}
return null;
}
/**
* 15.Drawable转换成Bitmap
*
* @author Sogrey
* @date 2015年5月20日
* @param drawable
* @return
*/
public static Bitmap drawable2Bitmap(Drawable drawable) {
Bitmap bitmap = Bitmap
.createBitmap(
drawable.getIntrinsicWidth(),
drawable.getIntrinsicHeight(),
drawable.getOpacity() != PixelFormat.OPAQUE ? Bitmap.Config.ARGB_8888
: Bitmap.Config.RGB_565);
Canvas canvas = new Canvas(bitmap);
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(),
drawable.getIntrinsicHeight());
drawable.draw(canvas);
return bitmap;
}
/**
* 16.Bitmap转换成Drawable
*
* @author Sogrey
* @date 2015年5月20日
* @param bitmap
* @return
*/
public static Drawable bitmap2Drawable(Bitmap bitmap) {
BitmapDrawable bd = new BitmapDrawable(bitmap);
Drawable d = (Drawable) bd;
return d;
}
/**
* 17.将view转为bitmap
*
* @author Sogrey
* @date 2015年5月20日
* @param view
* @return
*/
public static Bitmap getBitmapFromView(View view) {
// Define a bitmap with the same size as the view
Bitmap returnedBitmap = Bitmap.createBitmap(view.getWidth(),
view.getHeight(), Bitmap.Config.ARGB_8888);
// Bind a canvas to it
Canvas canvas = new Canvas(returnedBitmap);
// Get the view's background
Drawable bgDrawable = view.getBackground();
if (bgDrawable != null)
// has background drawable, then draw it on the canvas
bgDrawable.draw(canvas);
else
// does not have background drawable, then draw white background on
// the canvas
canvas.drawColor(Color.WHITE);
// draw the view on the canvas
view.draw(canvas);
// return the bitmap
return returnedBitmap;
}
/**
* 18.将view转为bitmap
*
* @author Sogrey
* @date 2015年5月20日
* @param view
* @return
*/
public static Bitmap viewToBitmap(View view) {
view.setDrawingCacheEnabled(true);
view.buildDrawingCache();
Bitmap bm = view.getDrawingCache();
return bm;
}
/**
* ==============参考资料===================
*
* 1.http://stackoverflow.com/questions/7200535/how-to-convert-views-to-
* bitmap
*
* 2.http://stackoverflow.com/questions/5536066/convert-view-to-bitmap-on-
* android/9595919#9595919
*
* 3.http://stackoverflow.com/questions/12402392/android-converting-xml-view
* -to-bitmap-without-showing-it
*/
/**
* 19.图片缩放与压缩-按大小缩放
*
* @author Sogrey
* @date 2015年5月20日
* @param srcPath
* @return
*/
public static Bitmap getimage(String srcPath) {
BitmapFactory.Options newOpts = new BitmapFactory.Options();
// 开始读入图片,此时把options.inJustDecodeBounds 设回true了
newOpts.inJustDecodeBounds = true;
Bitmap bitmap = BitmapFactory.decodeFile(srcPath, newOpts); // 此时返回bm为空
newOpts.inJustDecodeBounds = false;
int w = newOpts.outWidth;
int h = newOpts.outHeight;
// 现在主流手机比较多是800*480分辨率,所以高和宽我们设置为
float hh = 800f; // 这里设置高度为800f
float ww = 480f; // 这里设置宽度为480f
// 缩放比。由于是固定比例缩放,只用高或者宽其中一个数据进行计算即可
int be = 1; // be=1表示不缩放
if (w > h && w > ww) { // 如果宽度大的话根据宽度固定大小缩放
be = (int) (newOpts.outWidth / ww);
} else if (w < h && h > hh) { // 如果高度高的话根据宽度固定大小缩放
be = (int) (newOpts.outHeight / hh);
}
if (be <= 0)
be = 1;
newOpts.inSampleSize = be; // 设置缩放比例
// 重新读入图片,注意此时已经把options.inJustDecodeBounds 设回false了
bitmap = BitmapFactory.decodeFile(srcPath, newOpts);
return compressImage(bitmap); // 压缩好比例大小后再进行质量压缩
}
/**
* 20.图片质量压缩
*
* @author Sogrey
* @date 2015年5月20日
* @param image
* @return
*/
private static Bitmap compressImage(Bitmap image) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
image.compress(Bitmap.CompressFormat.JPEG, 100, baos); // 质量压缩方法,这里100表示不压缩,把压缩后的数据存放到baos中
int options = 100;
while (baos.toByteArray().length / 1024 > 100) { // 循环判断如果压缩后图片是否大于100kb,大于继续压缩
baos.reset(); // 重置baos即清空baos
image.compress(Bitmap.CompressFormat.JPEG, options, baos); // 这里压缩options%,把压缩后的数据存放到baos中
options -= 10; // 每次都减少10
}
ByteArrayInputStream isBm = new ByteArrayInputStream(baos.toByteArray()); // 把压缩后的数据baos存放到ByteArrayInputStream中
Bitmap bitmap = BitmapFactory.decodeStream(isBm, null, null); // 把ByteArrayInputStream数据生成图片
return bitmap;
}
/**
* 21.图片按比例大小压缩
*
* @author Sogrey
* @date 2015年5月20日
* @param image
* @return
*/
public static Bitmap comp(Bitmap image) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
image.compress(Bitmap.CompressFormat.JPEG, 100, baos);
if (baos.toByteArray().length / 1024 > 1024) { // 判断如果图片大于1M,进行压缩避免在生成图片(BitmapFactory.decodeStream)时溢出
baos.reset(); // 重置baos即清空baos
image.compress(Bitmap.CompressFormat.JPEG, 50, baos); // 这里压缩50%,把压缩后的数据存放到baos中
}
ByteArrayInputStream isBm = new ByteArrayInputStream(baos.toByteArray());
BitmapFactory.Options newOpts = new BitmapFactory.Options();
// 开始读入图片,此时把options.inJustDecodeBounds 设回true了
newOpts.inJustDecodeBounds = true;
Bitmap bitmap = BitmapFactory.decodeStream(isBm, null, newOpts);
newOpts.inJustDecodeBounds = false;
int w = newOpts.outWidth;
int h = newOpts.outHeight;
// 现在主流手机比较多是800*480分辨率,所以高和宽我们设置为
float hh = 800f; // 这里设置高度为800f
float ww = 480f; // 这里设置宽度为480f
// 缩放比。由于是固定比例缩放,只用高或者宽其中一个数据进行计算即可
int be = 1; // be=1表示不缩放
if (w > h && w > ww) { // 如果宽度大的话根据宽度固定大小缩放
be = (int) (newOpts.outWidth / ww);
} else if (w < h && h > hh) { // 如果高度高的话根据宽度固定大小缩放
be = (int) (newOpts.outHeight / hh);
}
if (be <= 0)
be = 1;
newOpts.inSampleSize = be; // 设置缩放比例
// 重新读入图片,注意此时已经把options.inJustDecodeBounds 设回false了
isBm = new ByteArrayInputStream(baos.toByteArray());
bitmap = BitmapFactory.decodeStream(isBm, null, newOpts);
return compressImage(bitmap); // 压缩好比例大小后再进行质量压缩
}
/**
* 22.图片转为文件
*
* @author Sogrey
* @date 2015年5月20日
* @param bmp
* @param filename
* @return
*/
public static boolean saveBitmap2file(Bitmap bmp, String filename) {
CompressFormat format = Bitmap.CompressFormat.JPEG;
int quality = 100;
OutputStream stream = null;
try {
stream = new FileOutputStream("/sdcard/" + filename);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
return bmp.compress(format, quality, stream);
}
/**
* 23.屏幕截屏方法<br>
* 屏幕截屏方法 获取当前屏幕bitmap,转换成bytes[] 调用 UI分享方法
*
* @author Sogrey
* @date 2015年5月20日
* @param context
* @param v
* @return
*/
@SuppressWarnings("deprecation")
public static Bitmap printscreen_share(Context context, View v) {
Activity activity = ((Activity) context);
View view1 = activity.getWindow().getDecorView();
Display display = activity.getWindowManager().getDefaultDisplay();
view1.layout(0, 0, display.getWidth(), display.getHeight());
view1.setDrawingCacheEnabled(true);
Bitmap bitmap = Bitmap.createBitmap(view1.getDrawingCache());
return bitmap;
}
/**
* 24.图片转为文件
*
* @author Sogrey
* @date 2015年5月20日
* @param bmp
* @param savePath
* @return
*/
@SuppressLint("NewApi")
public static boolean saveBitmap2filePath(Bitmap bmp, String savePath) {
CompressFormat format = Bitmap.CompressFormat.PNG;
int quality = 100;
OutputStream stream = null;
try {
// 判断SDcard状态
if (!Environment.MEDIA_MOUNTED.equals(Environment
.getExternalStorageState())) {
// 错误提示
return false;
}
// 检查SDcard空间
File SDCardRoot = Environment.getExternalStorageDirectory();
if (SDCardRoot.getFreeSpace() < 10000) {
// 弹出对话框提示用户空间不够
Log.e("Utils", "存储空间不够");
return false;
}
// 在SDcard创建文件夹及文件
File bitmapFile = new File(savePath);
bitmapFile.getParentFile().mkdirs(); // 创建文件夹
stream = new FileOutputStream(savePath); // "/sdcard/"
} catch (FileNotFoundException e) {
e.printStackTrace();
}
return bmp.compress(format, quality, stream);
}
/**
* 25.下载图片
*
* @author Sogrey
* @date 2015年5月20日
* @param params
* @return
*/
public static Bitmap loadImage(String... params) {
InputStream is = null;
Bitmap bitmap = null;
try {
URL url = new URL(params[0]);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setReadTimeout(5000);
conn.setConnectTimeout(5000);
if (HttpURLConnection.HTTP_OK != conn.getResponseCode()) {
// 网络连接异常
Log.e("", "loadImage连接异常");
return null;
}
is = conn.getInputStream();
bitmap = BitmapFactory.decodeStream(is);
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (null != is) {
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return bitmap;
}
/**
* 26.将字符串转换成Bitmap类型
*
* @author Sogrey
* @date 2015年5月20日
* @param string
* @return
*/
public static Bitmap stringtoBitmap(String string) {
// 将字符串转换成Bitmap类型
Bitmap bitmap = null;
try {
byte[] bitmapArray;
bitmapArray = Base64.decode(string, Base64.DEFAULT);
bitmap = BitmapFactory.decodeByteArray(bitmapArray, 0,
bitmapArray.length);
} catch (Exception e) {
e.printStackTrace();
}
return bitmap;
}
/**
* 27.将Bitmap转换成字符串
*
* @author Sogrey
* @date 2015年5月20日
* @param bitmap
* @return
*/
public static String bitmaptoString(Bitmap bitmap) {
// 将Bitmap转换成字符串
String string = null;
ByteArrayOutputStream bStream = new ByteArrayOutputStream();
bitmap.compress(CompressFormat.PNG, 100, bStream);
byte[] bytes = bStream.toByteArray();
string = Base64.encodeToString(bytes, Base64.DEFAULT);
return string;
}
/**
* 28.byte[]转为文件
*
* @author Sogrey
* @date 2015年5月20日
* @param b
* @param filePath
* @return
*/
@SuppressLint("NewApi")
public static File getFileFromBytes(byte[] b, String filePath) {
BufferedOutputStream stream = null;
File file = null;
try {
// 判断SDcard状态
if (!Environment.MEDIA_MOUNTED.equals(Environment
.getExternalStorageState())) {
// 错误提示
return null;
}
// 检查SDcard空间
File SDCardRoot = Environment.getExternalStorageDirectory();
if (SDCardRoot.getFreeSpace() < 10000) {
// 弹出对话框提示用户空间不够
Log.e("Utils", "存储空间不够");
return null;
}
// 在SDcard创建文件夹及文件
File bitmapFile = new File(filePath);
bitmapFile.getParentFile().mkdirs(); // 创建文件夹
FileOutputStream fstream = new FileOutputStream(bitmapFile);
stream = new BufferedOutputStream(fstream);
stream.write(b);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (stream != null) {
try {
stream.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
return file;
}
/**
* 29.图片缩放
*
* @author Sogrey
* @date 2015年5月20日
* @param photo
* @param newHeight
* @param context
* @return
*/
public static Bitmap scaleDownBitmap(Bitmap photo, int newHeight,
Context context) {
final float densityMultiplier = context.getResources()
.getDisplayMetrics().density;
int h = (int) (newHeight * densityMultiplier);
int w = (int) (h * photo.getWidth() / ((double) photo.getHeight()));
photo = Bitmap.createScaledBitmap(photo, w, h, true);
return photo;
}
}
| 29,264
|
https://github.com/foreignguymike/Sandbox/blob/master/core/src/com/distraction/sandbox/states/TransitionState.kt
|
Github Open Source
|
Open Source
|
MIT
| 2,022
|
Sandbox
|
foreignguymike
|
Kotlin
|
Code
| 177
| 516
|
package com.distraction.sandbox.states
import com.badlogic.gdx.graphics.Color
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.distraction.sandbox.Constants
import com.distraction.sandbox.Context
import com.distraction.sandbox.getAtlas
import com.distraction.sandbox.use
class TransitionState(context: Context, val nextState: GameState, val numPop: Int = 1) : GameState(context) {
private val dot = context.assets.getAtlas().findRegion("dot")
private val duration = 0.5f
private var time = 0f
private var next = false
init {
context.gsm.depth++
}
override fun update(dt: Float) {
time += dt
if (!next && time > duration / 2) {
next = true
nextState.ignoreInput = true
for (i in 0 until numPop) {
context.gsm.pop()
}
context.gsm.depth -= numPop - 1
context.gsm.replace(nextState)
context.gsm.push(this)
}
if (time > duration) {
context.gsm.depth--
context.gsm.pop()
nextState.ignoreInput = false
}
}
override fun render(sb: SpriteBatch) {
val interp = time / duration
val perc = if (interp < 0.5f) interp * 2f else 1f - (time - duration / 2) / duration * 2
val c = sb.color
sb.color = Color.BLACK
sb.projectionMatrix = camera.combined
sb.use {
sb.draw(dot, 0f, Constants.HEIGHT, 1f * Constants.WIDTH, -perc * Constants.HEIGHT / 2)
sb.draw(dot, 0f, 0f, 1f * Constants.WIDTH, perc * Constants.HEIGHT / 2)
}
sb.color = c
}
}
| 888
|
https://github.com/kids-first/kf-portal-ui/blob/master/src/components/UserProfile/ContactInformationEditable.js
|
Github Open Source
|
Open Source
|
Apache-2.0
| 2,023
|
kf-portal-ui
|
kids-first
|
JavaScript
|
Code
| 507
| 1,787
|
import React, { Fragment } from 'react';
import { Form, Input, Select, Typography } from 'antd';
import PropTypes from 'prop-types';
import { ROLES } from 'common/constants';
import AddressEditForm from 'components/UserProfile/AddressEditForm';
import { ERROR_TOO_MANY_CHARACTERS } from './constants';
import ContactEditablePlacesAutoComplete from './ContactEditablePlacesAutoComplete';
import { isResearcher, showInstitution } from './utils';
import './style.css';
const { fromEntries, entries } = Object;
const { Option } = Select;
const { Text } = Typography;
const MAX_LENGTH_FIELD = 100;
const ContactInformationEditable = (props) => {
const { setIsSaveButtonDisabledCB, data, parentForm, selectedRole } = props;
const { setFieldsValue } = parentForm;
const validateFieldsLength = (rule, value) => {
if (value && value.length > MAX_LENGTH_FIELD) {
setIsSaveButtonDisabledCB(true);
// eslint-disable-next-line no-undef
return Promise.reject(`${ERROR_TOO_MANY_CHARACTERS} ( max: ${MAX_LENGTH_FIELD} ) `);
}
setIsSaveButtonDisabledCB(false);
// eslint-disable-next-line no-undef
return Promise.resolve();
};
const commonLengthRuleValidator = () => ({
validator: validateFieldsLength,
});
/**
* Create a "hook" do disable the save button when an error is detected.
* Maybe there is a more elegant way to get things done but this code was migrated and it's
* the simplest solution that was found.
* */
const validateMandatory = (rule, value) => {
if (!value || !value.trim()) {
setIsSaveButtonDisabledCB(true);
// eslint-disable-next-line no-undef
return Promise.reject(); //Empty Message : let the message in "rules" show the message.
}
return validateFieldsLength(rule, value);
};
const commonRequiredRuleValidator = () => ({
validator: validateMandatory,
});
return (
<>
<div>
<Form.Item name="title" label="Title" rules={[{ required: false }]}>
<Select size={'small'}>
<Option value="">N/A</Option>
<Option value="mr">Mr.</Option>
<Option value="ms">Ms.</Option>
<Option value="mrs">Mrs.</Option>
<Option value="dr">Dr.</Option>
</Select>
</Form.Item>
<Form.Item name="roles" label="Profile Type" rules={[{ required: true }]}>
<Select size={'small'}>
{ROLES.map(({ type, displayName }) => (
<Option value={type} key={type}>
{displayName}
</Option>
))}
</Select>
</Form.Item>
<Input.Group>
<Form.Item
name="firstName"
label="First Name"
rules={[
{ required: true, message: 'first name is required' },
commonRequiredRuleValidator,
]}
>
<Input size="small" />
</Form.Item>
<Form.Item
name="lastName"
label="Last Name"
rules={[
{ required: true, message: 'last name is required' },
commonRequiredRuleValidator,
]}
>
<Input size="small" />
</Form.Item>
{showInstitution(selectedRole) && (
<Fragment>
<Form.Item
name="institution"
label="Institution/Organization"
rules={[{ required: true }, commonLengthRuleValidator]}
>
<Input size="small" />
</Form.Item>
</Fragment>
)}
<Form.Item
name="department"
label="Suborganization/Department"
rules={[{ required: false }, commonLengthRuleValidator]}
>
<Input size="small" />
</Form.Item>
{showInstitution(selectedRole) && (
<Fragment>
<Form.Item
name="institutionalEmail"
label="Institutional Email Address"
rules={[{ required: false }, commonLengthRuleValidator]}
>
<Input size="small" />
</Form.Item>
</Fragment>
)}
{isResearcher(selectedRole) && (
<Fragment>
<Form.Item
name="jobTitle"
label="Job Title"
rules={[{ required: false }, commonLengthRuleValidator]}
>
<Input size="small" />
</Form.Item>
</Fragment>
)}
<Form.Item
name="phone"
label="Phone"
rules={[{ required: false }, commonLengthRuleValidator]}
>
<Input size="small" />
</Form.Item>
<Form.Item
name="eraCommonsID"
label="ERA Commons ID"
rules={[{ required: false }, commonLengthRuleValidator]}
>
<Input size="small" />
</Form.Item>
</Input.Group>
</div>
<div>
<Text>Search Location</Text>
<ContactEditablePlacesAutoComplete
setAddressCb={(address) => {
const addressWithNonEmptyFields = fromEntries(
entries(address).filter(([, value]) => Boolean(value)),
);
setFieldsValue({ ...addressWithNonEmptyFields, addressLine2: undefined });
}}
/>
</div>
<div className={'contact-edit-address-wrapper'}>
<AddressEditForm
parentForm={parentForm}
validateFieldsCB={validateFieldsLength}
addressLine1={data.addressLine1}
addressLine2={data.addressLine2}
city={data.city}
country={data.country}
state={data.state}
zip={data.zip}
/>
</div>
</>
);
};
ContactInformationEditable.propTypes = {
data: PropTypes.shape({
roles: PropTypes.arrayOf(PropTypes.string),
title: PropTypes.string,
firstName: PropTypes.string,
lastName: PropTypes.string,
phone: PropTypes.string,
institution: PropTypes.string,
department: PropTypes.string,
eraCommonsID: PropTypes.string,
institutionalEmail: PropTypes.string,
addressLine1: PropTypes.string,
addressLine2: PropTypes.string,
city: PropTypes.string,
country: PropTypes.string,
state: PropTypes.string,
zip: PropTypes.string,
}).isRequired,
setIsSaveButtonDisabledCB: PropTypes.func.isRequired,
parentForm: PropTypes.shape({
setFieldsValue: PropTypes.func.isRequired,
getFieldValue: PropTypes.func.isRequired,
}),
selectedRole: PropTypes.string.isRequired,
};
export default ContactInformationEditable;
| 33,884
|
https://github.com/FlandreCirno/AzurLaneWikiUtilitiesManual/blob/master/AzurLaneData/zh-CN/gamecfg/story/weicenghunhe33.lua
|
Github Open Source
|
Open Source
|
MIT
| 2,021
|
AzurLaneWikiUtilitiesManual
|
FlandreCirno
|
Lua
|
Code
| 1,376
| 4,767
|
return {
fadeOut = 1.5,
mode = 2,
id = "WEICENGHUNHE33",
once = true,
fadeType = 1,
fadein = 1.5,
scripts = {
{
say = "要塞东侧外海?·海雾中",
side = 2,
bgName = "bg_xiangting_3",
dir = 1,
bgmDelay = 1,
bgm = "xinnong-3",
flashin = {
delay = 1,
dur = 1,
black = true,
alpha = {
1,
0
}
},
effects = {
{
active = true,
name = "miwu_01"
}
},
typewriter = {
speed = 0.05,
speedUp = 0.01
},
painting = {
alpha = 0.3,
time = 1
}
},
{
dir = 1,
side = 2,
bgName = "bg_xiangting_3",
say = "巴尔的摩带领的调防舰队正在迷雾中与净化者激烈战斗着----",
typewriter = {
speed = 0.05,
speedUp = 0.01
},
painting = {
alpha = 0.3,
time = 1
}
},
{
actor = 900021,
nameColor = "#ff5c5c",
bgName = "bg_xiangting_3",
side = 2,
dir = 1,
actorName = "净化者",
say = "才怪呢~!",
typewriter = {
speed = 0.05,
speedUp = 0.01
},
painting = {
alpha = 0.3,
time = 1
}
},
{
actor = 103160,
side = 2,
bgName = "bg_xiangting_3",
nameColor = "#a9f548",
dir = 1,
say = "喂,不要躲躲闪闪的,来和我正面战斗啊!",
typewriter = {
speed = 0.05,
speedUp = 0.01
},
painting = {
alpha = 0.3,
time = 1
}
},
{
expression = 1,
side = 2,
bgName = "bg_xiangting_3",
nameColor = "#ff5c5c",
dir = 1,
actor = 900021,
actorName = "净化者",
say = "才不要~这次可不是为了收集数据,我才不想浪费无谓的力气呢。",
typewriter = {
speed = 0.05,
speedUp = 0.01
},
painting = {
alpha = 0.3,
time = 1
}
},
{
expression = 2,
side = 2,
bgName = "bg_xiangting_3",
actor = 102160,
dir = 1,
nameColor = "#a9f548",
say = "明明是这么明目张胆的拖延战术…可是我们却一点办法都没有……!",
typewriter = {
speed = 0.05,
speedUp = 0.01
},
painting = {
alpha = 0.3,
time = 1
}
},
{
say = "轰-----!",
side = 2,
bgName = "bg_xiangting_3",
dir = 1,
soundeffect = "event:/battle/boom2",
flashN = {
color = {
1,
1,
1
},
alpha = {
{
0,
1,
0.2
},
{
1,
0,
0.2,
0.2
},
{
0,
1,
0.2,
0.4
},
{
1,
0,
0.2,
0.6
}
}
},
dialogShake = {
speed = 0.09,
x = 8.5,
number = 2
},
typewriter = {
speed = 0.05,
speedUp = 0.01
},
painting = {
alpha = 0.3,
time = 1
}
},
{
expression = 4,
side = 2,
bgName = "bg_xiangting_3",
actor = 102050,
dir = 1,
nameColor = "#a9f548",
say = "这片海域里,还有人在战斗!",
typewriter = {
speed = 0.05,
speedUp = 0.01
},
painting = {
alpha = 0.3,
time = 1
}
},
{
expression = 2,
side = 2,
bgName = "bg_xiangting_3",
nameColor = "#ff5c5c",
dir = 1,
actor = 900021,
actorName = "净化者",
say = "(诱饵舰队被摧毁了,终于上钩了么)",
typewriter = {
speed = 0.05,
speedUp = 0.01
},
painting = {
alpha = 0.3,
time = 1
}
},
{
expression = 3,
side = 2,
bgName = "bg_xiangting_3",
nameColor = "#ff5c5c",
dir = 1,
actor = 900021,
actorName = "净化者",
say = "啊--这-可-不-太-妙---要-撤-退-了----(棒读)",
typewriter = {
speed = 0.05,
speedUp = 0.01
},
painting = {
alpha = 0.3,
time = 1
},
action = {
{
type = "move",
y = 0,
delay = 1,
dur = 0.5,
x = -2500
}
}
},
{
actor = 103160,
side = 2,
bgName = "bg_xiangting_3",
nameColor = "#a9f548",
dir = 1,
say = "等-----!",
typewriter = {
speed = 0.05,
speedUp = 0.01
},
painting = {
alpha = 0.3,
time = 1
},
action = {
{
type = "shake",
y = 30,
delay = 0,
dur = 0.15,
x = 0,
number = 2
}
}
},
{
dir = 1,
side = 2,
bgName = "bg_xiangting_3",
say = "几乎在净化者驶出视野的同时,一个“熟悉”的身影伴随着爆炸的余音从迷雾中出现了。",
typewriter = {
speed = 0.05,
speedUp = 0.01
},
painting = {
alpha = 0.3,
time = 1
}
},
{
actor = 900135,
nameColor = "#ffa500",
bgName = "bg_xiangting_3",
side = 2,
dir = 1,
actorName = "???",
say = "………",
typewriter = {
speed = 0.05,
speedUp = 0.01
},
painting = {
alpha = 0.3,
time = 1
}
},
{
actor = 103160,
side = 2,
bgName = "bg_xiangting_3",
nameColor = "#a9f548",
dir = 1,
say = "…余、余烬--?!!",
dialogShake = {
speed = 0.09,
x = 10,
number = 2
},
typewriter = {
speed = 0.05,
speedUp = 0.01
},
painting = {
alpha = 0.3,
time = 1
}
},
{
actor = 900135,
nameColor = "#ffa500",
bgName = "bg_xiangting_3",
side = 2,
dir = 1,
actorName = "???",
say = "这次你们的指挥官没跟着一起来么。",
typewriter = {
speed = 0.05,
speedUp = 0.01
},
painting = {
alpha = 0.3,
time = 1
}
},
{
expression = 1,
side = 2,
bgName = "bg_xiangting_3",
actor = 103160,
dir = 1,
nameColor = "#a9f548",
say = "……无可奉告",
typewriter = {
speed = 0.05,
speedUp = 0.01
},
painting = {
alpha = 0.3,
time = 1
}
},
{
actor = 900135,
nameColor = "#ffa500",
bgName = "bg_xiangting_3",
side = 2,
dir = 1,
actorName = "???",
say = "这样啊………(转身)",
typewriter = {
speed = 0.05,
speedUp = 0.01
},
painting = {
alpha = 0.3,
time = 1
}
},
{
expression = 3,
side = 2,
bgName = "bg_xiangting_3",
actor = 102160,
dir = 1,
nameColor = "#a9f548",
say = "请…请等一下!谢谢你出来帮助我们!",
typewriter = {
speed = 0.05,
speedUp = 0.01
},
painting = {
alpha = 0.3,
time = 1
},
action = {
{
type = "shake",
y = 30,
delay = 0,
dur = 0.15,
x = 0,
number = 2
}
}
},
{
actor = 900135,
nameColor = "#ffa500",
bgName = "bg_xiangting_3",
side = 2,
dir = 1,
actorName = "???",
say = "……",
typewriter = {
speed = 0.05,
speedUp = 0.01
},
painting = {
alpha = 0.3,
time = 1
}
},
{
expression = 2,
side = 2,
bgName = "bg_xiangting_3",
actor = 102160,
dir = 1,
nameColor = "#a9f548",
say = "请问!你知道这些海雾究竟是什么东西么…",
typewriter = {
speed = 0.05,
speedUp = 0.01
},
painting = {
alpha = 0.3,
time = 1
}
},
{
actor = 900135,
nameColor = "#ffa500",
bgName = "bg_xiangting_3",
side = 2,
dir = 1,
actorName = "???",
say = "…塞壬用来掩护行军和围困敌人的把戏。",
typewriter = {
speed = 0.05,
speedUp = 0.01
},
painting = {
alpha = 0.3,
time = 1
}
},
{
expression = 4,
side = 2,
bgName = "bg_xiangting_3",
actor = 102050,
dir = 1,
nameColor = "#a9f548",
say = "居然在迷雾中偏航了这么远,明明就算通过海水的变化也应该早就能察觉到的…",
typewriter = {
speed = 0.05,
speedUp = 0.01
},
painting = {
alpha = 0.3,
time = 1
}
},
{
actor = 900135,
nameColor = "#ffa500",
bgName = "bg_xiangting_3",
side = 2,
dir = 1,
actorName = "???",
say = "「微层化混合物」,这片海雾的正式名字。整天被那些家伙耍,什么时候才能成长些啊…",
typewriter = {
speed = 0.05,
speedUp = 0.01
},
painting = {
alpha = 0.3,
time = 1
}
},
{
actor = 103160,
side = 2,
bgName = "bg_xiangting_3",
nameColor = "#a9f548",
dir = 1,
say = "果然是这片海雾干的好事啊…糟糕了。",
dialogShake = {
speed = 0.09,
x = 10,
number = 2
},
typewriter = {
speed = 0.05,
speedUp = 0.01
},
painting = {
alpha = 0.3,
time = 1
}
},
{
expression = 1,
side = 2,
bgName = "bg_xiangting_3",
actor = 102160,
dir = 1,
nameColor = "#a9f548",
say = "那…请问我们能回去了么?我们还有很紧急的任务要做…",
typewriter = {
speed = 0.05,
speedUp = 0.01
},
painting = {
alpha = 0.3,
time = 1
}
},
{
actor = 103160,
side = 2,
bgName = "bg_xiangting_3",
nameColor = "#a9f548",
dir = 1,
say = "当然,如果要选择打一场的话,我们也奉陪哦!",
typewriter = {
speed = 0.05,
speedUp = 0.01
},
painting = {
alpha = 0.3,
time = 1
}
},
{
actor = 900135,
nameColor = "#ffa500",
bgName = "bg_xiangting_3",
side = 2,
dir = 1,
actorName = "???",
say = "……真麻烦。",
typewriter = {
speed = 0.05,
speedUp = 0.01
},
painting = {
alpha = 0.3,
time = 1
}
},
{
actor = 900135,
nameColor = "#ffa500",
bgName = "bg_xiangting_3",
side = 2,
dir = 1,
blackBg = true,
actorName = "???",
say = "唉…之前看到的侦察机飞来的方向,我记得是…………",
typewriter = {
speed = 0.05,
speedUp = 0.01
},
painting = {
alpha = 0.3,
time = 1
}
}
}
}
| 4,330
|
https://github.com/robdyke/packer-windows-1/blob/master/scripts/version.sh
|
Github Open Source
|
Open Source
|
MIT
| 2,018
|
packer-windows-1
|
robdyke
|
Shell
|
Code
| 23
| 52
|
#!/bin/bash
az vm image list -p MicrosoftWindowsDesktop -s RS3-Pro -f Windows-10 --all -o tsv --query '[].version' | sort -u | tail -n 1
| 5,179
|
https://github.com/apache/mesos/blob/master/3rdparty/cmake/FindLIBSECCOMP.cmake
|
Github Open Source
|
Open Source
|
Apache-2.0, GPL-2.0-or-later, BSD-3-Clause, LicenseRef-scancode-unknown-license-reference, LicenseRef-scancode-protobuf, LGPL-2.1-only, PSF-2.0, BSL-1.0, MIT, LicenseRef-scancode-warranty-disclaimer, BSD-2-Clause
| 2,023
|
mesos
|
apache
|
CMake
|
Code
| 176
| 511
|
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
include(FindPackageHelper)
# TODO(tillt): Consider moving "_ROOT_DIR" logic into FindPackageHelper.
if ("${LIBSECCOMP_ROOT_DIR}" STREQUAL "")
set(POSSIBLE_LIBSECCOMP_INCLUDE_DIRS "")
set(POSSIBLE_LIBSECCOMP_LIB_DIRS "")
if (NOT "${LIBSECCOMP_PREFIX}" STREQUAL "")
list(APPEND POSSIBLE_LIBSECCOMP_INCLUDE_DIRS ${LIBSECCOMP_PREFIX}/include)
list(APPEND POSSIBLE_LIBSECCOMP_LIB_DIRS ${LIBSECCOMP_PREFIX}/lib)
endif()
list(
APPEND POSSIBLE_LIBSECCOMP_INCLUDE_DIRS
/usr/include/
/usr/local/include/)
list(
APPEND POSSIBLE_LIBSECCOMP_LIB_DIRS
/usr/lib
/usr/local/lib)
else()
set(POSSIBLE_LIBSECCOMP_INCLUDE_DIRS ${LIBSECCOMP_ROOT_DIR}/include)
set(POSSIBLE_LIBSECCOMP_LIB_DIRS ${LIBSECCOMP_ROOT_DIR}/lib)
endif()
set(LIBSECCOMP_LIBRARY_NAMES seccomp)
FIND_PACKAGE_HELPER(LIBSECCOMP seccomp.h)
| 3,468
|
https://github.com/feiyangtang97/swan/blob/master/swan_core/src/main/java/de/fraunhofer/iem/swan/Loader.java
|
Github Open Source
|
Open Source
|
BSD-3-Clause
| null |
swan
|
feiyangtang97
|
Java
|
Code
| 295
| 969
|
package de.fraunhofer.iem.swan;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import de.fraunhofer.iem.swan.data.Category;
import de.fraunhofer.iem.swan.data.Method;
import de.fraunhofer.iem.swan.features.AbstractSootFeature;
import soot.Scene;
import soot.SootClass;
import soot.SootMethod;
public class Loader {
private final String testCp;
private Set<Method> methods = new HashSet<Method>();
public Loader(String testCp) {
this.testCp = testCp;
}
public Set<Method> methods() {
return methods;
}
public void resetMethods() {
for (Method m : methods) {
if (m.getCategoryClassified() != null
&& !m.getCategoryClassified().equals(Category.NONE))
m.addCategoryClassified(m.getCategoryClassified());
m.setCategoryClassified(null);
}
}
public void loadTestSet(final Set<String> testClasses,
final Set<Method> trainingSet) {
loadMethodsFromTestLib(testClasses);
Util.createSubclassAnnotations(methods, testCp);
methods = Util.sanityCheck(methods, trainingSet);
Util.printStatistics("Test set complete", methods);
}
private void loadMethodsFromTestLib(final Set<String> testClasses) {
int methodCount = methods.size();
new AbstractSootFeature(testCp) {
@Override
public Type appliesInternal(Method method) {
for (String className : testClasses) {
SootClass sc = Scene.v().forceResolve(className, SootClass.HIERARCHY);
if (sc == null) continue;
if (!testClasses.contains(sc.getName())) continue;
if (!sc.isInterface() && !sc.isPrivate())
for (SootMethod sm : sc.getMethods()) {
if (sm.isConcrete()) {
// This is done by hand here because of the cases where the
// character ' is in the signature. This is not supported by the
// current Soot.
// TODO: Get Soot to support the character '
String sig = sm.getSignature();
sig = sig.substring(sig.indexOf(": ") + 2, sig.length());
String returnType = sig.substring(0, sig.indexOf(" "));
String methodName =
sig.substring(sig.indexOf(" ") + 1, sig.indexOf("("));
List<String> parameters = new ArrayList<String>();
for (String parameter : sig
.substring(sig.indexOf("(") + 1, sig.indexOf(")"))
.split(",")) {
if (!parameter.trim().isEmpty())
parameters.add(parameter.trim());
}
Method newMethod =
new Method(methodName, parameters, returnType, className);
//System.out.println(newMethod.getSignature());
methods.add(newMethod);
}
}
}
return Type.NOT_SUPPORTED;
}
}.applies(new Method("a", "void", "x.y"));
//System.out.println("Loaded " + (methods.size() - methodCount) + " methods from the test JAR.");
}
public void pruneNone() {
Set<Method> newMethods = new HashSet<Method>();
for (Method m : methods) {
if (!m.getCategoriesClassified().isEmpty())
newMethods.add(m);
}
//System.out.println( methods.size() + " methods prunned down to " + newMethods.size());
methods = newMethods;
}
}
| 26,278
|
https://github.com/llop/pac-man/blob/master/Assets/Scripts/Powerups/EffectAction.cs
|
Github Open Source
|
Open Source
|
MIT
| 2,021
|
pac-man
|
llop
|
C#
|
Code
| 17
| 44
|
using UnityEngine;
[RequireComponent (typeof (BoxCollider))]
public abstract class EffectAction : MonoBehaviour
{
public abstract void triggerAction();
}
| 30,518
|
https://github.com/BugsUK/FindApprenticeship/blob/master/src/SFA.Apprenticeships.Infrastructure.Elastic.Common/Entities/IVacancySummary.cs
|
Github Open Source
|
Open Source
|
MIT
| 2,021
|
FindApprenticeship
|
BugsUK
|
C#
|
Code
| 76
| 178
|
namespace SFA.Apprenticeships.Infrastructure.Elastic.Common.Entities
{
using System;
public interface IVacancySummary
{
int Id { get; }
string Title { get; set; }
DateTime ClosingDate { get; set; }
DateTime PostedDate { get; set; }
string EmployerName { get; set; }
string ProviderName { get; set; }
string Description { get; set; }
int NumberOfPositions { get; set; }
GeoPoint Location { get; set; }
string VacancyReference { get; set; }
string Category { get; set; }
}
}
| 18,843
|
https://github.com/aartrama/aartrama.github.io/blob/master/node_modules/@effect-ts/system/_mjs/Experimental/Stream/_internal/api/someOrElse.mjs
|
Github Open Source
|
Open Source
|
MIT
| 2,023
|
aartrama.github.io
|
aartrama
|
JavaScript
|
Code
| 66
| 171
|
// ets_tracing: off
import * as O from "../../../../Option/index.mjs";
import * as Map from "./map.mjs";
/**
* Extracts the optional value, or returns the given 'default'.
*/
export function someOrElse_(self, default_) {
return Map.map_(self, O.getOrElseS(() => default_));
}
/**
* Extracts the optional value, or returns the given 'default'.
*
* @ets_data_first someOrElse_
*/
export function someOrElse(default_) {
return self => someOrElse_(self, default_);
}
//# sourceMappingURL=someOrElse.mjs.map
| 33,597
|
https://github.com/BastiaanJansen/algorithms-and-data-structures/blob/master/src/main/java/DataStructures/Lists/LinkedList.java
|
Github Open Source
|
Open Source
|
MIT
| null |
algorithms-and-data-structures
|
BastiaanJansen
|
Java
|
Code
| 52
| 145
|
package DataStructures.Lists;
/**
* @author Bastiaan Jansen
* @see List
* @param <T>
*/
public interface LinkedList<T> extends List<T> {
void addFirst(T element);
void addLast(T element);
T getFirst();
T getLast();
T removeFirst();
T removeLast();
interface Node<T> {
Node<T> getLast();
boolean contains(T element);
int size(int n);
int find(T element);
boolean hasNext();
}
}
| 33,175
|
https://github.com/PieterjanDeconinck/quarkus/blob/master/integration-tests/mongodb-client/src/main/java/io/quarkus/it/mongodb/discriminator/jsonb/VehicleDeserializer.java
|
Github Open Source
|
Open Source
|
Apache-2.0
| 2,022
|
quarkus
|
PieterjanDeconinck
|
Java
|
Code
| 94
| 370
|
package io.quarkus.it.mongodb.discriminator.jsonb;
import java.lang.reflect.Type;
import javax.json.JsonObject;
import javax.json.bind.serializer.DeserializationContext;
import javax.json.bind.serializer.JsonbDeserializer;
import javax.json.stream.JsonParser;
import io.quarkus.it.mongodb.discriminator.Car;
import io.quarkus.it.mongodb.discriminator.Moto;
import io.quarkus.it.mongodb.discriminator.Vehicle;
public class VehicleDeserializer implements JsonbDeserializer<Vehicle> {
@Override
public Vehicle deserialize(JsonParser parser, DeserializationContext ctx, Type rtType) {
JsonObject json = parser.getObject();
String type = json.getString("type");
switch (type) {
case "CAR":
Car car = new Car();
car.type = type;
car.seatNumber = json.getInt("seatNumber");
car.name = json.getString("name");
return car;
case "MOTO":
Moto moto = new Moto();
moto.type = type;
moto.name = json.getString("name");
moto.sideCar = json.getBoolean("sideCar");
return moto;
default:
throw new RuntimeException("Type " + type + "not managed");
}
}
}
| 27,624
|
https://github.com/3m1n3nc3/PasscontestV2/blob/master/application/libraries/Creative_lib.php
|
Github Open Source
|
Open Source
|
LicenseRef-scancode-unknown-license-reference, MIT
| 2,020
|
PasscontestV2
|
3m1n3nc3
|
PHP
|
Code
| 809
| 2,622
|
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class Creative_lib {
function __construct() {
$this->CI = & get_instance();
$this->CI->load->helper('date');
}
public function resize_image($src = '', $_config = '')
{
$config['image_library'] = isset($_config['image_library']) ? $_config['image_library'] : 'gd2';
$config['maintain_ratio'] = isset($_config['maintain_ratio']) ? $_config['maintain_ratio'] : TRUE;
$config['width'] = isset($_config['width']) ? $_config['width'] : 450;
$config['height'] = isset($_config['height'])? $_config['height'] : 450;
$config['source_image'] = $src;
$this->CI->load->library('image_lib', $config);
if ( ! $this->CI->image_lib->resize() )
{
return $this->CI->image_lib->display_errors();
}
else
{
chmod($config['source_image'],0777);
return TRUE;
}
}
public function create_dir($path = '', $error = null)
{
if (file_exists($path)) {
if(is_writable($path))
{
return TRUE;
}
else
{
if (!chmod($path, 0777))
{
return FALSE;
}
return TRUE;
}
}
elseif (!$error)
{
$mkdir = mkdir($path, 0777, TRUE);
return $mkdir;
}
return FALSE;
}
public function delete_file($file_path = '')
{
if (is_array($file_path))
{
foreach ($file_path as $path)
{
if (file_exists($path) && is_file($path))
{
chmod($path, 0777);
return unlink($path);
}
}
}
else
{
if (file_exists($file_path) && is_file($file_path))
{
chmod($file_path, 0777);
return unlink($file_path);
}
}
return FALSE;
}
public function fetch_image($src = '', $type = 1)
{
if ($src && file_exists('./'.$src)) {
return base_url().$src;
} else {
return base_url().'resources/img/ryan.jpg';//'.$type.'.png';
}
}
public function get_section($name = '', $key = '')
{
$section = $this->CI->content_model->get_sections(['name' => $name], true);
if ($section) {
if ($key) {
if (isset($section[$key])) {
$data = $section[$key];
} else {
$data = ucwords($name);
}
} else {
$data = $section;
}
} else {
$data = ucwords($name);
}
return $data;
}
public function yearly_sales($year = '')
{
$year_data = [];
$years = $this->CI->dashboard_model->sales_stats_year();
foreach ($years as $yd) {
$last_year_stats = $stats_month1 = [];
$this_year_stats = $stats_month2 = [];
$last_year = $this->CI->dashboard_model->sales_stats(['year' => $yd['last_year']]);
$this_year = $this->CI->dashboard_model->sales_stats(['year' => $yd['this_year']]);
foreach ($last_year as $lastm) {
$last_year_stats[] .= $lastm['sales'];
$stats_month1[] .= '\''.$this->int_to_month($lastm['month']).'\'';
}
foreach ($this_year as $thism) {
$this_year_stats[] .= $thism['sales'];
$stats_month2[] .= '\''.$this->int_to_month($thism['month']).'\'';
}
}
$labels = array_unique(array_merge($stats_month1, $stats_month2));
$labels = $this->month_rearray($labels);
$stats_data =
'data: {
labels: ['.implode(', ',$labels).'],
datasets: [
{
backgroundColor: \'#ced4da\',
borderColor : \'#ced4da\',
data: ['.implode(', ', $last_year_stats).']
},
{
backgroundColor: \'#007bff\',
borderColor : \'#007bff\',
data: ['.implode(', ', $this_year_stats).']
}
]
}';
return $stats_data;
}
public function month_rearray($months = array(), $lt = "'", $rt = "'")
{
$keys = array_values($months);
if ( in_array( $lt . 'January' . $rt, $keys) or in_array( $lt . 'Jan' . $rt, $keys) )
{
$key_data[1] = $lt . 'January' . $rt;
}
if ( in_array( $lt . 'February' . $rt, $keys) or in_array( $lt . 'Feb' . $rt, $keys) )
{
$key_data[2] = $lt . 'February'.$rt;
}
if ( in_array( $lt . 'March' . $rt, $keys) or in_array( $lt . 'Mar' . $rt, $keys) )
{
$key_data[3] = $lt . 'March'.$rt;
}
if ( in_array( $lt . 'April' . $rt, $keys) or in_array( $lt . 'Apr' . $rt, $keys) )
{
$key_data[4] = $lt . 'April'.$rt;
}
if ( in_array( $lt . 'May' . $rt, $keys) or in_array( $lt . 'May' . $rt, $keys) )
{
$key_data[5] = $lt . 'May'.$rt;
}
if ( in_array( $lt . 'June' . $rt, $keys) or in_array( $lt . 'Jun' . $rt, $keys) )
{
$key_data[6] = $lt . 'June'.$rt;
}
if ( in_array( $lt . 'July' . $rt, $keys) or in_array( $lt . 'Jul' . $rt, $keys) )
{
$key_data[7] = $lt . 'July'.$rt;
}
if ( in_array( $lt . 'August' . $rt, $keys) or in_array( $lt . 'Aug' . $rt, $keys) )
{
$key_data[8] = $lt . 'August'.$rt;
}
if ( in_array( $lt . 'September' . $rt, $keys) or in_array( $lt . 'Sept' . $rt, $keys) )
{
$key_data[9] = $lt . 'September'.$rt;
}
if ( in_array( $lt . 'October' . $rt, $keys) or in_array( $lt . 'Oct' . $rt, $keys) )
{
$key_data[10] = $lt . 'October'.$rt;
}
if ( in_array( $lt . 'November' . $rt, $keys) or in_array( $lt . 'Nov' . $rt, $keys) )
{
$key_data[11] = $lt . 'November'.$rt;
}
if ( in_array( $lt . 'December' . $rt, $keys) or in_array( $lt . 'Dec' . $rt, $keys) )
{
$key_data[12] = $lt . 'December'.$rt;
}
return array_values($key_data);
}
public function int_to_month($int = 1, $short = False)
{
switch ($int) {
case 1:
$month = 'January';
break;
case 2:
$month = 'February';
break;
case 3:
$month = 'March';
break;
case 4:
$month = 'April';
break;
case 5:
$month = 'May';
break;
case 6:
$month = 'June';
break;
case 7:
$month = 'July';
break;
case 8:
$month = 'August';
break;
case 9:
$month = 'September';
break;
case 10:
$month = 'October';
break;
case 11:
$month = 'November';
break;
default:
$month = 'December';
break;
}
if ($short) {
return date('M', strtotime($month));
}
return $month;
}
public function default_card($str = '')
{
if (!$str) {
$str = 'There is currently nothing to show, keep exploring other parts of the site to see exiting contents!';
}
$card = '
<div class="card text-center">
<a href="#">
<div class="card-background-top" style="background-image: url(\''.$this->fetch_image('').'\')"></div>
</a>
<div class="card-body">
<h3 class="card-text text-danger">'.$str.'</h3>
</div>
</div>';
return $card;
}
}
| 45,453
|
https://github.com/Ljazz/studyspace/blob/master/Python tripartite framework/Django/code/mysite/session/forms.py
|
Github Open Source
|
Open Source
|
MIT
| null |
studyspace
|
Ljazz
|
Python
|
Code
| 14
| 60
|
from django import forms
class LoginForm(forms.Form):
username = forms.CharField(label='用户名', max_length=30)
password = forms.CharField(label='密码', max_length=30)
| 33,714
|
https://github.com/lzap/dynflow/blob/master/test/persistence_test.rb
|
Github Open Source
|
Open Source
|
MIT
| null |
dynflow
|
lzap
|
Ruby
|
Code
| 729
| 3,071
|
require_relative 'test_helper'
module Dynflow
module PersistenceTest
describe 'persistence adapters' do
let :execution_plans_data do
[{ id: 'plan1', :label => 'test1', state: 'paused' },
{ id: 'plan2', :label => 'test2', state: 'stopped' },
{ id: 'plan3', :label => 'test3', state: 'paused' },
{ id: 'plan4', :label => 'test4', state: 'paused' }]
end
let :action_data do
{ id: 1, caller_execution_plan_id: nil, caller_action_id: nil }
end
let :step_data do
{ id: 1,
state: 'success',
started_at: '2015-02-24 10:00',
ended_at: '2015-02-24 10:01',
real_time: 1.1,
execution_time: 0.1,
action_id: 1,
progress_done: 1,
progress_weight: 2.5 }
end
def prepare_plans
execution_plans_data.map do |h|
h.merge result: nil, started_at: (Time.now-20).to_s, ended_at: (Time.now-10).to_s,
real_time: 0.0, execution_time: 0.0
end.tap do |plans|
plans.each { |plan| adapter.save_execution_plan(plan[:id], plan) }
end
end
def format_time(time)
time.strftime('%Y-%m-%d %H:%M:%S')
end
def prepare_action(plan)
adapter.save_action(plan, action_data[:id], action_data)
end
def prepare_step(plan)
adapter.save_step(plan, step_data[:id], step_data)
end
def prepare_plans_with_actions
prepare_plans.each do |plan|
prepare_action(plan[:id])
end
end
def prepare_plans_with_steps
prepare_plans_with_actions.map do |plan|
prepare_step(plan[:id])
end
end
# rubocop:disable Metrics/AbcSize,Metrics/MethodLength
def self.it_acts_as_persistence_adapter
before do
# the tests expect clean field
adapter.delete_execution_plans({})
end
describe '#find_execution_plans' do
it 'supports pagination' do
prepare_plans
if adapter.pagination?
loaded_plans = adapter.find_execution_plans(page: 0, per_page: 1)
loaded_plans.map { |h| h[:id] }.must_equal ['plan1']
loaded_plans = adapter.find_execution_plans(page: 1, per_page: 1)
loaded_plans.map { |h| h[:id] }.must_equal ['plan2']
end
end
it 'supports ordering' do
prepare_plans
if adapter.ordering_by.include?('state')
loaded_plans = adapter.find_execution_plans(order_by: 'state')
loaded_plans.map { |h| h[:id] }.must_equal %w(plan1 plan3 plan4 plan2)
loaded_plans = adapter.find_execution_plans(order_by: 'state', desc: true)
loaded_plans.map { |h| h[:id] }.must_equal %w(plan2 plan1 plan3 plan4)
end
end
it 'supports filtering' do
prepare_plans
if adapter.ordering_by.include?('state')
loaded_plans = adapter.find_execution_plans(filters: { label: ['test1'] })
loaded_plans.map { |h| h[:id] }.must_equal ['plan1']
loaded_plans = adapter.find_execution_plans(filters: { state: ['paused'] })
loaded_plans.map { |h| h[:id] }.must_equal ['plan1', 'plan3', 'plan4']
loaded_plans = adapter.find_execution_plans(filters: { state: ['stopped'] })
loaded_plans.map { |h| h[:id] }.must_equal ['plan2']
loaded_plans = adapter.find_execution_plans(filters: { state: [] })
loaded_plans.map { |h| h[:id] }.must_equal []
loaded_plans = adapter.find_execution_plans(filters: { state: ['stopped', 'paused'] })
loaded_plans.map { |h| h[:id] }.must_equal %w(plan1 plan2 plan3 plan4)
loaded_plans = adapter.find_execution_plans(filters: { 'state' => ['stopped', 'paused'] })
loaded_plans.map { |h| h[:id] }.must_equal %w(plan1 plan2 plan3 plan4)
loaded_plans = adapter.find_execution_plans(filters: { label: ['test1'], :delayed => true })
loaded_plans.must_be_empty
adapter.save_delayed_plan('plan1',
:execution_plan_uuid => 'plan1',
:start_at => format_time(Time.now + 60),
:start_before => format_time(Time.now - 60))
loaded_plans = adapter.find_execution_plans(filters: { label: ['test1'], :delayed => true })
loaded_plans.map { |h| h[:id] }.must_equal ['plan1']
end
end
end
describe '#load_execution_plan and #save_execution_plan' do
it 'serializes/deserializes the plan data' do
-> { adapter.load_execution_plan('plan1') }.must_raise KeyError
prepare_plans
adapter.load_execution_plan('plan1')[:id].must_equal 'plan1'
adapter.load_execution_plan('plan1')['id'].must_equal 'plan1'
adapter.load_execution_plan('plan1').keys.size.must_equal 8
adapter.save_execution_plan('plan1', nil)
-> { adapter.load_execution_plan('plan1') }.must_raise KeyError
end
end
describe '#delete_execution_plans' do
it 'deletes selected execution plans, including steps and actions' do
prepare_plans_with_steps
adapter.delete_execution_plans('uuid' => 'plan1').must_equal 1
-> { adapter.load_execution_plan('plan1') }.must_raise KeyError
-> { adapter.load_action('plan1', action_data[:id]) }.must_raise KeyError
-> { adapter.load_step('plan1', step_data[:id]) }.must_raise KeyError
# testing that no other plans where affected
adapter.load_execution_plan('plan2')
adapter.load_action('plan2', action_data[:id])
adapter.load_step('plan2', step_data[:id])
prepare_plans_with_steps
adapter.delete_execution_plans('state' => 'paused').must_equal 3
-> { adapter.load_execution_plan('plan1') }.must_raise KeyError
adapter.load_execution_plan('plan2') # nothing raised
-> { adapter.load_execution_plan('plan3') }.must_raise KeyError
end
end
describe '#load_action and #save_action' do
it 'serializes/deserializes the action data' do
prepare_plans
action_id = action_data[:id]
-> { adapter.load_action('plan1', action_id) }.must_raise KeyError
prepare_action('plan1')
loaded_action = adapter.load_action('plan1', action_id)
loaded_action[:id].must_equal action_id
loaded_action.must_equal(Utils.stringify_keys(action_data))
adapter.save_action('plan1', action_id, nil)
-> { adapter.load_action('plan1', action_id) }.must_raise KeyError
adapter.save_execution_plan('plan1', nil)
end
end
describe '#load_step and #save_step' do
it 'serializes/deserializes the step data' do
prepare_plans_with_actions
step_id = step_data[:id]
prepare_step('plan1')
loaded_step = adapter.load_step('plan1', step_id)
loaded_step[:id].must_equal step_id
loaded_step.must_equal(Utils.stringify_keys(step_data))
end
end
describe '#find_past_delayed_plans' do
it 'finds plans with start_before in past' do
start_time = Time.now
prepare_plans
adapter.save_delayed_plan('plan1', :execution_plan_uuid => 'plan1', :start_at => format_time(start_time + 60),
:start_before => format_time(start_time - 60))
adapter.save_delayed_plan('plan2', :execution_plan_uuid => 'plan2', :start_at => format_time(start_time - 60))
adapter.save_delayed_plan('plan3', :execution_plan_uuid => 'plan3', :start_at => format_time(start_time + 60))
adapter.save_delayed_plan('plan4', :execution_plan_uuid => 'plan4', :start_at => format_time(start_time - 60),
:start_before => format_time(start_time - 60))
plans = adapter.find_past_delayed_plans(start_time)
plans.length.must_equal 3
plans.map { |plan| plan[:execution_plan_uuid] }.must_equal %w(plan2 plan4 plan1)
end
end
end
describe Dynflow::PersistenceAdapters::Sequel do
let(:adapter) { Dynflow::PersistenceAdapters::Sequel.new 'sqlite:/' }
it_acts_as_persistence_adapter
it 'allows inspecting the persisted content' do
plans = prepare_plans
plans.each do |original|
stored = adapter.to_hash.fetch(:execution_plans).find { |ep| ep[:uuid].strip == original[:id] }
stored.each { |k, v| stored[k] = v.to_s if v.is_a? Time }
adapter.class::META_DATA.fetch(:execution_plan).each do |name|
stored.fetch(name.to_sym).must_equal original.fetch(name.to_sym)
end
end
end
it "supports connector's needs for exchaning envelopes" do
client_world_id = '5678'
executor_world_id = '1234'
envelope_hash = ->(envelope) { Dynflow::Utils.indifferent_hash(Dynflow.serializer.dump(envelope)) }
executor_envelope = envelope_hash.call(Dispatcher::Envelope[123, client_world_id, executor_world_id, Dispatcher::Execution['111']])
client_envelope = envelope_hash.call(Dispatcher::Envelope[123, executor_world_id, client_world_id, Dispatcher::Accepted])
envelopes = [client_envelope, executor_envelope]
envelopes.each { |e| adapter.push_envelope(e) }
assert_equal [executor_envelope], adapter.pull_envelopes(executor_world_id)
assert_equal [client_envelope], adapter.pull_envelopes(client_world_id)
assert_equal [], adapter.pull_envelopes(client_world_id)
assert_equal [], adapter.pull_envelopes(executor_world_id)
end
end
end
end
end
| 2,428
|
https://github.com/luongnvUIT/prowide-iso20022/blob/master/model-seev-types/src/generated/java/com/prowidesoftware/swift/model/mx/dic/ProcessingPosition2Code.java
|
Github Open Source
|
Open Source
|
Apache-2.0
| 2,022
|
prowide-iso20022
|
luongnvUIT
|
Java
|
Code
| 147
| 457
|
package com.prowidesoftware.swift.model.mx.dic;
import javax.xml.bind.annotation.XmlEnum;
import javax.xml.bind.annotation.XmlType;
/**
* <p>Java class for ProcessingPosition2Code.
*
* <p>The following schema fragment specifies the expected content contained within this class.
* <p>
* <pre>
* <simpleType name="ProcessingPosition2Code">
* <restriction base="{http://www.w3.org/2001/XMLSchema}string">
* <enumeration value="AFTE"/>
* <enumeration value="WITH"/>
* <enumeration value="BEFO"/>
* <enumeration value="INFO"/>
* </restriction>
* </simpleType>
* </pre>
*
*/
@XmlType(name = "ProcessingPosition2Code")
@XmlEnum
public enum ProcessingPosition2Code {
/**
* Specifies that the transaction/instruction is to be executed after the linked transaction/instruction.
*
*/
AFTE,
/**
* Specifies that the transaction/instruction is to be executed with the linked transaction/instruction.
*
*/
WITH,
/**
* Specifies that the transaction/instruction is to be executed before the linked transaction/instruction.
*
*/
BEFO,
/**
* Specifies that the transactions/instructions are linked for information purposes only.
*
*/
INFO;
public String value() {
return name();
}
public static ProcessingPosition2Code fromValue(String v) {
return valueOf(v);
}
}
| 39,968
|
https://github.com/eontool/electron-starter-app/blob/master/source/app.ts
|
Github Open Source
|
Open Source
|
MIT
| null |
electron-starter-app
|
eontool
|
TypeScript
|
Code
| 81
| 306
|
//Common libraries
import * as jQuery from 'jquery';
import * as angular from 'angular';
import 'angular-ui-router';
window.$ = window.jQuery = jQuery;
//Constants
import Constants from './constants/app.constant';
//Configuration
import Routes from './configuration/routes.config';
import Transitions from './configuration/transitions.config';
import Interceptors from './configuration/interceptors.config';
//Controllers
import MainController from './controllers/main.controller';
import AuthCtrl from './controllers/auth.controller';
//Services
import Animation from './services/animation.service';
import TemplateService from './services/template.service';
//Factories
import GenericInterceptor from './factories/interceptor.factory';
angular
.module('MainApp', ['ui.router', 'templates'])
.constant('Constants', Constants())
.config(Routes)
.config(Interceptors)
.run(Transitions)
.service('Animation', Animation)
.service('TemplateService', TemplateService)
.controller('MainController', MainController)
.controller('AuthCtrl', AuthCtrl)
.factory('GenericInterceptor', GenericInterceptor.factory)
| 38,879
|
https://github.com/RobotCasserole1736/TestSwervePlantModel/blob/master/src/main/java/frc/robot/Drivetrain/DrivetrainPoseEstimator.java
|
Github Open Source
|
Open Source
|
MIT
| 2,022
|
TestSwervePlantModel
|
RobotCasserole1736
|
Java
|
Code
| 364
| 1,457
|
package frc.robot.Drivetrain;
import org.photonvision.PhotonCamera;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.estimator.SwerveDrivePoseEstimator;
import edu.wpi.first.wpilibj.geometry.Pose2d;
import edu.wpi.first.wpilibj.geometry.Rotation2d;
import edu.wpi.first.wpilibj.geometry.Transform2d;
import edu.wpi.first.wpilibj.kinematics.SwerveModuleState;
import edu.wpi.first.wpilibj.util.Units;
import edu.wpi.first.wpiutil.math.VecBuilder;
import frc.Constants;
import frc.lib.DataServer.Annotations.Signal;
public class DrivetrainPoseEstimator {
/* Singleton infrastructure */
private static DrivetrainPoseEstimator instance;
public static DrivetrainPoseEstimator getInstance() {
if (instance == null) {
instance = new DrivetrainPoseEstimator();
}
return instance;
}
Pose2d curEstPose = new Pose2d(Constants.DFLT_START_POSE.getTranslation(), Constants.DFLT_START_POSE.getRotation());
Pose2d fieldPose = new Pose2d(); //Field-referenced orign
Pose2d visionEstPose = null; //Camera-reported raw pose. null if no pose available.
PhotonCamera cam;
WrapperedADXRS450 gyro;
boolean pointedDownfield = false;
SwerveDrivePoseEstimator m_poseEstimator;
@Signal(units = "ft/sec")
double curSpeed = 0;
private DrivetrainPoseEstimator(){
gyro = new WrapperedADXRS450();
cam = new PhotonCamera(Constants.PHOTON_CAM_NAME);
//Trustworthiness of the internal model of how motors should be moving
// Measured in expected standard deviation (meters of position and degrees of rotation)
var stateStdDevs = VecBuilder.fill(0.05, 0.05, Units.degreesToRadians(5));
//Trustworthiness of gyro in radians of standard deviation.
var localMeasurementStdDevs = VecBuilder.fill(Units.degreesToRadians(0.1));
//Trustworthiness of the vision system
// Measured in expected standard deviation (meters of position and degrees of rotation)
var visionMeasurementStdDevs = VecBuilder.fill(0.01, 0.01, Units.degreesToRadians(0.1));
m_poseEstimator = new SwerveDrivePoseEstimator(getGyroHeading(),
Constants.DFLT_START_POSE,
Constants.m_kinematics,
stateStdDevs,
localMeasurementStdDevs,
visionMeasurementStdDevs,
Constants.CTRLS_SAMPLE_RATE_SEC);
setKnownPose(Constants.DFLT_START_POSE);
}
/**
* Snap update the estimator to a known pose.
* @param in known pose
*/
public void setKnownPose(Pose2d in){
DrivetrainControl.getInstance().resetWheelEncoders();
//No need to reset gyro, pose estimator does that.
m_poseEstimator.resetPosition(in, getGyroHeading());
updateDownfieldFlag();
curEstPose = in;
}
public Pose2d getEstPose(){ return curEstPose; }
public Pose2d getVisionEstPose(){ return visionEstPose; }
public void update(){
//Based on gyro and measured module speeds and positions, estimate where our robot should have moved to.
SwerveModuleState[] states = DrivetrainControl.getInstance().getModuleActualStates();
Pose2d prevEstPose = curEstPose;
curEstPose = m_poseEstimator.update(getGyroHeading(), states[0], states[1], states[2], states[3]);
//If we see a vision target, adjust our pose estimate
var res = cam.getLatestResult();
if(res.hasTargets()){
double observationTime = Timer.getFPGATimestamp() - res.getLatencyMillis();
Transform2d camToTargetTrans = res.getBestTarget().getCameraToTarget();
Pose2d targetPose = fieldPose.transformBy(pointedDownfield ? Constants.fieldToFarVisionTargetTrans:Constants.fieldToCloseVisionTargetTrans);
Pose2d camPose = targetPose.transformBy(camToTargetTrans.inverse());
visionEstPose = camPose.transformBy(Constants.robotToCameraTrans.inverse());
m_poseEstimator.addVisionMeasurement(visionEstPose, observationTime);
} else {
visionEstPose = null;
}
//Calculate a "speedometer" velocity in ft/sec
Transform2d deltaPose = new Transform2d(prevEstPose, curEstPose);
curSpeed = Units.metersToFeet(deltaPose.getTranslation().getNorm()) / Constants.CTRLS_SAMPLE_RATE_SEC;
updateDownfieldFlag();
}
public Rotation2d getGyroHeading(){
return gyro.getAngle().times(-1.0);
}
public double getSpeedFtpSec(){
return curSpeed;
}
public void updateDownfieldFlag(){
double curRotDeg = curEstPose.getRotation().getDegrees();
pointedDownfield = (curRotDeg > -90 && curRotDeg < 90);
}
}
| 25,638
|
https://github.com/Zematus/Worlds/blob/master/Assets/Scripts/WorldEngine/Modding/Entities/Utility Entities/IResettableEntity.cs
|
Github Open Source
|
Open Source
|
MIT
| 2,022
|
Worlds
|
Zematus
|
C#
|
Code
| 13
| 32
|
using System;
using UnityEngine;
public interface IResettableEntity : IEntity
{
void Reset();
}
| 38,958
|
https://github.com/apache/aries/blob/master/transaction/transaction-jms/src/main/java/org/apache/aries/transaction/jms/PooledConnectionFactory.java
|
Github Open Source
|
Open Source
|
Apache-2.0
| 2,023
|
aries
|
apache
|
Java
|
Code
| 2,652
| 5,573
|
/**
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.aries.transaction.jms;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.JMSException;
import javax.jms.XAConnection;
import javax.jms.XAConnectionFactory;
import org.apache.aries.transaction.jms.internal.ConnectionKey;
import org.apache.aries.transaction.jms.internal.ConnectionPool;
import org.apache.aries.transaction.jms.internal.PooledConnection;
import org.apache.commons.pool.KeyedPoolableObjectFactory;
import org.apache.commons.pool.impl.GenericKeyedObjectPool;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* A JMS provider which pools Connection, Session and MessageProducer instances
* so it can be used with tools like <a href="http://camel.apache.org/activemq.html">Camel</a> and Spring's
* <a href="http://activemq.apache.org/spring-support.html">JmsTemplate and MessagListenerContainer</a>.
* Connections, sessions and producers are returned to a pool after use so that they can be reused later
* without having to undergo the cost of creating them again.
*
* b>NOTE:</b> while this implementation does allow the creation of a collection of active consumers,
* it does not 'pool' consumers. Pooling makes sense for connections, sessions and producers, which
* are expensive to create and can remain idle a minimal cost. Consumers, on the other hand, are usually
* just created at startup and left active, handling incoming messages as they come. When a consumer is
* complete, it is best to close it rather than return it to a pool for later reuse: this is because,
* even if a consumer is idle, ActiveMQ will keep delivering messages to the consumer's prefetch buffer,
* where they'll get held until the consumer is active again.
*
* If you are creating a collection of consumers (for example, for multi-threaded message consumption), you
* might want to consider using a lower prefetch value for each consumer (e.g. 10 or 20), to ensure that
* all messages don't end up going to just one of the consumers. See this FAQ entry for more detail:
* http://activemq.apache.org/i-do-not-receive-messages-in-my-second-consumer.html
*
* Optionally, one may configure the pool to examine and possibly evict objects as they sit idle in the
* pool. This is performed by an "idle object eviction" thread, which runs asynchronously. Caution should
* be used when configuring this optional feature. Eviction runs contend with client threads for access
* to objects in the pool, so if they run too frequently performance issues may result. The idle object
* eviction thread may be configured using the {@link PooledConnectionFactory#setTimeBetweenExpirationCheckMillis} method. By
* default the value is -1 which means no eviction thread will be run. Set to a non-negative value to
* configure the idle eviction thread to run.
*
* @org.apache.xbean.XBean element="pooledConnectionFactory"
*/
public class PooledConnectionFactory implements ConnectionFactory {
private static final transient Logger LOG = LoggerFactory.getLogger(PooledConnectionFactory.class);
protected final AtomicBoolean stopped = new AtomicBoolean(false);
private GenericKeyedObjectPool<ConnectionKey, ConnectionPool> connectionsPool;
private ConnectionFactory connectionFactory;
private int maximumActiveSessionPerConnection = 500;
private int idleTimeout = 30 * 1000;
private boolean blockIfSessionPoolIsFull = true;
private long blockIfSessionPoolIsFullTimeout = -1L;
private long expiryTimeout = 0l;
private boolean createConnectionOnStartup = true;
private boolean useAnonymousProducers = true;
public void initConnectionsPool() {
if (this.connectionsPool == null) {
this.connectionsPool = new GenericKeyedObjectPool<ConnectionKey, ConnectionPool>(
new KeyedPoolableObjectFactory<ConnectionKey, ConnectionPool>() {
@Override
public void activateObject(ConnectionKey key, ConnectionPool connection) throws Exception {
}
@Override
public void destroyObject(ConnectionKey key, ConnectionPool connection) throws Exception {
try {
if (LOG.isTraceEnabled()) {
LOG.trace("Destroying connection: {}", connection);
}
connection.close();
} catch (Exception e) {
LOG.warn("Close connection failed for connection: " + connection + ". This exception will be ignored.",e);
}
}
@Override
public ConnectionPool makeObject(ConnectionKey key) throws Exception {
Connection delegate = createConnection(key);
ConnectionPool connection = createConnectionPool(delegate);
connection.setIdleTimeout(getIdleTimeout());
connection.setExpiryTimeout(getExpiryTimeout());
connection.setMaximumActiveSessionPerConnection(getMaximumActiveSessionPerConnection());
connection.setBlockIfSessionPoolIsFull(isBlockIfSessionPoolIsFull());
if (isBlockIfSessionPoolIsFull() && getBlockIfSessionPoolIsFullTimeout() > 0) {
connection.setBlockIfSessionPoolIsFullTimeout(getBlockIfSessionPoolIsFullTimeout());
}
connection.setUseAnonymousProducers(isUseAnonymousProducers());
if (LOG.isTraceEnabled()) {
LOG.trace("Created new connection: {}", connection);
}
return connection;
}
@Override
public void passivateObject(ConnectionKey key, ConnectionPool connection) throws Exception {
}
@Override
public boolean validateObject(ConnectionKey key, ConnectionPool connection) {
if (connection != null && connection.expiredCheck()) {
if (LOG.isTraceEnabled()) {
LOG.trace("Connection has expired: {} and will be destroyed", connection);
}
return false;
}
return true;
}
});
// Set max idle (not max active) since our connections always idle in the pool.
this.connectionsPool.setMaxIdle(1);
// We always want our validate method to control when idle objects are evicted.
this.connectionsPool.setTestOnBorrow(true);
this.connectionsPool.setTestWhileIdle(true);
}
}
/**
* @return the currently configured ConnectionFactory used to create the pooled Connections.
*/
public ConnectionFactory getConnectionFactory() {
return connectionFactory;
}
/**
* Sets the ConnectionFactory used to create new pooled Connections.
* <p/>
* Updates to this value do not affect Connections that were previously created and placed
* into the pool. In order to allocate new Connections based off this new ConnectionFactory
* it is first necessary to {@link #clear()} the pooled Connections.
*
* @param toUse
* The factory to use to create pooled Connections.
*/
public void setConnectionFactory(final ConnectionFactory toUse) {
if (toUse instanceof XAConnectionFactory) {
this.connectionFactory = new XAConnectionFactoryWrapper((XAConnectionFactory) toUse);
} else {
this.connectionFactory = toUse;
}
}
@Override
public Connection createConnection() throws JMSException {
return createConnection(null, null);
}
@Override
public synchronized Connection createConnection(String userName, String password) throws JMSException {
if (stopped.get()) {
LOG.debug("PooledConnectionFactory is stopped, skip create new connection.");
return null;
}
ConnectionPool connection = null;
ConnectionKey key = new ConnectionKey(userName, password);
// This will either return an existing non-expired ConnectionPool or it
// will create a new one to meet the demand.
if (getConnectionsPool().getNumIdle(key) < getMaxConnections()) {
try {
// we want borrowObject to return the one we added.
connectionsPool.setLifo(true);
connectionsPool.addObject(key);
} catch (Exception e) {
throw createJmsException("Error while attempting to add new Connection to the pool", e);
}
} else {
// now we want the oldest one in the pool.
connectionsPool.setLifo(false);
}
try {
// We can race against other threads returning the connection when there is an
// expiration or idle timeout. We keep pulling out ConnectionPool instances until
// we win and get a non-closed instance and then increment the reference count
// under lock to prevent another thread from triggering an expiration check and
// pulling the rug out from under us.
while (connection == null) {
connection = connectionsPool.borrowObject(key);
synchronized (connection) {
if (connection.getConnection() != null) {
connection.incrementReferenceCount();
break;
}
// Return the bad one to the pool and let if get destroyed as normal.
connectionsPool.returnObject(key, connection);
connection = null;
}
}
} catch (Exception e) {
throw createJmsException("Error while attempting to retrieve a connection from the pool", e);
}
try {
connectionsPool.returnObject(key, connection);
} catch (Exception e) {
throw createJmsException("Error when returning connection to the pool", e);
}
return newPooledConnection(connection);
}
protected Connection newPooledConnection(ConnectionPool connection) {
return new PooledConnection(connection);
}
private JMSException createJmsException(String msg, Exception cause) {
JMSException exception = new JMSException(msg);
exception.setLinkedException(cause);
exception.initCause(cause);
return exception;
}
protected Connection createConnection(ConnectionKey key) throws JMSException {
if (key.getUserName() == null && key.getPassword() == null) {
return connectionFactory.createConnection();
} else {
return connectionFactory.createConnection(key.getUserName(), key.getPassword());
}
}
public void start() {
LOG.debug("Staring the PooledConnectionFactory: create on start = {}", isCreateConnectionOnStartup());
stopped.set(false);
if (isCreateConnectionOnStartup()) {
try {
// warm the pool by creating a connection during startup
createConnection();
} catch (JMSException e) {
LOG.warn("Create pooled connection during start failed. This exception will be ignored.", e);
}
}
}
public void stop() {
if (stopped.compareAndSet(false, true)) {
LOG.debug("Stopping the PooledConnectionFactory, number of connections in cache: {}",
connectionsPool != null ? connectionsPool.getNumActive() : 0);
try {
if (connectionsPool != null) {
connectionsPool.close();
}
} catch (Exception e) {
}
}
}
/**
* Clears all connections from the pool. Each connection that is currently in the pool is
* closed and removed from the pool. A new connection will be created on the next call to
* {@link #createConnection()}. Care should be taken when using this method as Connections that
* are in use be client's will be closed.
*/
public void clear() {
if (stopped.get()) {
return;
}
getConnectionsPool().clear();
}
/**
* Returns the currently configured maximum number of sessions a pooled Connection will
* create before it either blocks or throws an exception when a new session is requested,
* depending on configuration.
*
* @return the number of session instances that can be taken from a pooled connection.
*/
public int getMaximumActiveSessionPerConnection() {
return maximumActiveSessionPerConnection;
}
/**
* Sets the maximum number of active sessions per connection
*
* @param maximumActiveSessionPerConnection
* The maximum number of active session per connection in the pool.
*/
public void setMaximumActiveSessionPerConnection(int maximumActiveSessionPerConnection) {
this.maximumActiveSessionPerConnection = maximumActiveSessionPerConnection;
}
/**
* Controls the behavior of the internal session pool. By default the call to
* Connection.getSession() will block if the session pool is full. If the
* argument false is given, it will change the default behavior and instead the
* call to getSession() will throw a JMSException.
*
* The size of the session pool is controlled by the @see #maximumActive
* property.
*
* @param block - if true, the call to getSession() blocks if the pool is full
* until a session object is available. defaults to true.
*/
public void setBlockIfSessionPoolIsFull(boolean block) {
this.blockIfSessionPoolIsFull = block;
}
/**
* Returns whether a pooled Connection will enter a blocked state or will throw an Exception
* once the maximum number of sessions has been borrowed from the the Session Pool.
*
* @return true if the pooled Connection createSession method will block when the limit is hit.
* @see #setBlockIfSessionPoolIsFull(boolean)
*/
public boolean isBlockIfSessionPoolIsFull() {
return this.blockIfSessionPoolIsFull;
}
/**
* Returns the maximum number to pooled Connections that this factory will allow before it
* begins to return connections from the pool on calls to ({@link #createConnection()}.
*
* @return the maxConnections that will be created for this pool.
*/
public int getMaxConnections() {
return getConnectionsPool().getMaxIdle();
}
/**
* Sets the maximum number of pooled Connections (defaults to one). Each call to
* {@link #createConnection()} will result in a new Connection being create up to the max
* connections value.
*
* @param maxConnections the maxConnections to set
*/
public void setMaxConnections(int maxConnections) {
getConnectionsPool().setMaxIdle(maxConnections);
}
/**
* Gets the Idle timeout value applied to new Connection's that are created by this pool.
* <p/>
* The idle timeout is used determine if a Connection instance has sat to long in the pool unused
* and if so is closed and removed from the pool. The default value is 30 seconds.
*
* @return idle timeout value (milliseconds)
*/
public int getIdleTimeout() {
return idleTimeout;
}
/**
* Sets the idle timeout value for Connection's that are created by this pool in Milliseconds,
* defaults to 30 seconds.
* <p/>
* For a Connection that is in the pool but has no current users the idle timeout determines how
* long the Connection can live before it is eligible for removal from the pool. Normally the
* connections are tested when an attempt to check one out occurs so a Connection instance can sit
* in the pool much longer than its idle timeout if connections are used infrequently.
*
* @param idleTimeout
* The maximum time a pooled Connection can sit unused before it is eligible for removal.
*/
public void setIdleTimeout(int idleTimeout) {
this.idleTimeout = idleTimeout;
}
/**
* allow connections to expire, irrespective of load or idle time. This is useful with failover
* to force a reconnect from the pool, to reestablish load balancing or use of the master post recovery
*
* @param expiryTimeout non zero in milliseconds
*/
public void setExpiryTimeout(long expiryTimeout) {
this.expiryTimeout = expiryTimeout;
}
/**
* @return the configured expiration timeout for connections in the pool.
*/
public long getExpiryTimeout() {
return expiryTimeout;
}
/**
* @return true if a Connection is created immediately on a call to {@link #start()}.
*/
public boolean isCreateConnectionOnStartup() {
return createConnectionOnStartup;
}
/**
* Whether to create a connection on starting this {@link PooledConnectionFactory}.
* <p/>
* This can be used to warm-up the pool on startup. Notice that any kind of exception
* happens during startup is logged at WARN level and ignored.
*
* @param createConnectionOnStartup <tt>true</tt> to create a connection on startup
*/
public void setCreateConnectionOnStartup(boolean createConnectionOnStartup) {
this.createConnectionOnStartup = createConnectionOnStartup;
}
/**
* Should Sessions use one anonymous producer for all producer requests or should a new
* MessageProducer be created for each request to create a producer object, default is true.
*
* When enabled the session only needs to allocate one MessageProducer for all requests and
* the MessageProducer#send(destination, message) method can be used. Normally this is the
* right thing to do however it does result in the Broker not showing the producers per
* destination.
*
* @return true if a PooledSession will use only a single anonymous message producer instance.
*/
public boolean isUseAnonymousProducers() {
return this.useAnonymousProducers;
}
/**
* Sets whether a PooledSession uses only one anonymous MessageProducer instance or creates
* a new MessageProducer for each call the create a MessageProducer.
*
* @param value
* Boolean value that configures whether anonymous producers are used.
*/
public void setUseAnonymousProducers(boolean value) {
this.useAnonymousProducers = value;
}
/**
* Gets the Pool of ConnectionPool instances which are keyed by different ConnectionKeys.
*
* @return this factories pool of ConnectionPool instances.
*/
protected GenericKeyedObjectPool<ConnectionKey, ConnectionPool> getConnectionsPool() {
initConnectionsPool();
return this.connectionsPool;
}
/**
* Sets the number of milliseconds to sleep between runs of the idle Connection eviction thread.
* When non-positive, no idle object eviction thread will be run, and Connections will only be
* checked on borrow to determine if they have sat idle for too long or have failed for some
* other reason.
* <p/>
* By default this value is set to -1 and no expiration thread ever runs.
*
* @param timeBetweenExpirationCheckMillis
* The time to wait between runs of the idle Connection eviction thread.
*/
public void setTimeBetweenExpirationCheckMillis(long timeBetweenExpirationCheckMillis) {
getConnectionsPool().setTimeBetweenEvictionRunsMillis(timeBetweenExpirationCheckMillis);
}
/**
* @return the number of milliseconds to sleep between runs of the idle connection eviction thread.
*/
public long getTimeBetweenExpirationCheckMillis() {
return getConnectionsPool().getTimeBetweenEvictionRunsMillis();
}
/**
* @return the number of Connections currently in the Pool
*/
public int getNumConnections() {
return getConnectionsPool().getNumIdle();
}
/**
* Delegate that creates each instance of an ConnectionPool object. Subclasses can override
* this method to customize the type of connection pool returned.
*
* @param connection
*
* @return instance of a new ConnectionPool.
*/
protected ConnectionPool createConnectionPool(Connection connection) {
return new ConnectionPool(connection);
}
/**
* Returns the timeout to use for blocking creating new sessions
*
* @return true if the pooled Connection createSession method will block when the limit is hit.
* @see #setBlockIfSessionPoolIsFull(boolean)
*/
public long getBlockIfSessionPoolIsFullTimeout() {
return blockIfSessionPoolIsFullTimeout;
}
/**
* Controls the behavior of the internal session pool. By default the call to
* Connection.getSession() will block if the session pool is full. This setting
* will affect how long it blocks and throws an exception after the timeout.
*
* The size of the session pool is controlled by the @see #maximumActive
* property.
*
* Whether or not the call to create session blocks is controlled by the @see #blockIfSessionPoolIsFull
* property
*
* @param blockIfSessionPoolIsFullTimeout - if blockIfSessionPoolIsFullTimeout is true,
* then use this setting to configure how long to block before retry
*/
public void setBlockIfSessionPoolIsFullTimeout(long blockIfSessionPoolIsFullTimeout) {
this.blockIfSessionPoolIsFullTimeout = blockIfSessionPoolIsFullTimeout;
}
static class XAConnectionFactoryWrapper implements XAConnectionFactory, ConnectionFactory {
private final XAConnectionFactory delegate;
XAConnectionFactoryWrapper(XAConnectionFactory delegate) {
this.delegate = delegate;
}
@Override
public Connection createConnection() throws JMSException {
return createXAConnection();
}
@Override
public Connection createConnection(String userName, String password) throws JMSException {
return createXAConnection(userName, password);
}
@Override
public XAConnection createXAConnection() throws JMSException {
return delegate.createXAConnection();
}
@Override
public XAConnection createXAConnection(String userName, String password) throws JMSException {
return delegate.createXAConnection(userName, password);
}
}
}
| 50,759
|
https://github.com/SBCV/blender/blob/master/intern/opensubdiv/internal/topology/topology_refiner_impl_compare.cc
|
Github Open Source
|
Open Source
|
Naumen, Condor-1.1, MS-PL
| 2,022
|
blender
|
SBCV
|
C++
|
Code
| 504
| 1,638
|
// Copyright 2018 Blender Foundation. All rights reserved.
//
// 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 2
// 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, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
// Author: Sergey Sharybin
#include "internal/topology/topology_refiner_impl.h"
#include "internal/base/type.h"
#include "internal/base/type_convert.h"
#include "internal/topology/mesh_topology.h"
#include "internal/topology/topology_refiner_impl.h"
#include "opensubdiv_converter_capi.h"
namespace blender {
namespace opensubdiv {
namespace {
const OpenSubdiv::Far::TopologyRefiner *getOSDTopologyRefiner(
const TopologyRefinerImpl *topology_refiner_impl)
{
return topology_refiner_impl->topology_refiner;
}
const OpenSubdiv::Far::TopologyLevel &getOSDTopologyBaseLevel(
const TopologyRefinerImpl *topology_refiner_impl)
{
return getOSDTopologyRefiner(topology_refiner_impl)->GetLevel(0);
}
////////////////////////////////////////////////////////////////////////////////
// Quick preliminary checks.
bool checkSchemeTypeMatches(const TopologyRefinerImpl *topology_refiner_impl,
const OpenSubdiv_Converter *converter)
{
const OpenSubdiv::Sdc::SchemeType converter_scheme_type =
blender::opensubdiv::getSchemeTypeFromCAPI(converter->getSchemeType(converter));
return (converter_scheme_type == getOSDTopologyRefiner(topology_refiner_impl)->GetSchemeType());
}
bool checkOptionsMatches(const TopologyRefinerImpl *topology_refiner_impl,
const OpenSubdiv_Converter *converter)
{
typedef OpenSubdiv::Sdc::Options Options;
const Options options = getOSDTopologyRefiner(topology_refiner_impl)->GetSchemeOptions();
const Options::FVarLinearInterpolation fvar_interpolation = options.GetFVarLinearInterpolation();
const Options::FVarLinearInterpolation converter_fvar_interpolation =
blender::opensubdiv::getFVarLinearInterpolationFromCAPI(
converter->getFVarLinearInterpolation(converter));
if (fvar_interpolation != converter_fvar_interpolation) {
return false;
}
return true;
}
bool checkPreliminaryMatches(const TopologyRefinerImpl *topology_refiner_impl,
const OpenSubdiv_Converter *converter)
{
return checkSchemeTypeMatches(topology_refiner_impl, converter) &&
checkOptionsMatches(topology_refiner_impl, converter);
}
////////////////////////////////////////////////////////////////////////////////
// Compare attributes which affects on topology.
//
// TODO(sergey): Need to look into how auto-winding affects on face-varying
// indexing and, possibly, move to mesh topology as well if winding affects
// face-varyign as well.
bool checkSingleUVLayerMatch(const OpenSubdiv::Far::TopologyLevel &base_level,
const OpenSubdiv_Converter *converter,
const int layer_index)
{
converter->precalcUVLayer(converter, layer_index);
const int num_faces = base_level.GetNumFaces();
// TODO(sergey): Need to check whether converter changed the winding of
// face to match OpenSubdiv's expectations.
for (int face_index = 0; face_index < num_faces; ++face_index) {
OpenSubdiv::Far::ConstIndexArray base_level_face_uvs = base_level.GetFaceFVarValues(
face_index, layer_index);
for (int corner = 0; corner < base_level_face_uvs.size(); ++corner) {
const int uv_index = converter->getFaceCornerUVIndex(converter, face_index, corner);
if (base_level_face_uvs[corner] != uv_index) {
converter->finishUVLayer(converter);
return false;
}
}
}
converter->finishUVLayer(converter);
return true;
}
bool checkUVLayersMatch(const TopologyRefinerImpl *topology_refiner_impl,
const OpenSubdiv_Converter *converter)
{
using OpenSubdiv::Far::TopologyLevel;
const int num_layers = converter->getNumUVLayers(converter);
const TopologyLevel &base_level = getOSDTopologyBaseLevel(topology_refiner_impl);
// Number of UV layers should match.
if (base_level.GetNumFVarChannels() != num_layers) {
return false;
}
for (int layer_index = 0; layer_index < num_layers; ++layer_index) {
if (!checkSingleUVLayerMatch(base_level, converter, layer_index)) {
return false;
}
}
return true;
}
bool checkTopologyAttributesMatch(const TopologyRefinerImpl *topology_refiner_impl,
const OpenSubdiv_Converter *converter)
{
return checkUVLayersMatch(topology_refiner_impl, converter);
}
} // namespace
bool TopologyRefinerImpl::isEqualToConverter(const OpenSubdiv_Converter *converter) const
{
if (!blender::opensubdiv::checkPreliminaryMatches(this, converter)) {
return false;
}
if (!base_mesh_topology.isEqualToConverter(converter)) {
return false;
}
// NOTE: Do after geometry check, to be sure topology does match and all
// indexing will go fine.
if (!blender::opensubdiv::checkTopologyAttributesMatch(this, converter)) {
return false;
}
return true;
}
} // namespace opensubdiv
} // namespace blender
| 42,353
|
https://github.com/123343103/fushikang_docker/blob/master/project/php_project/api/modules/warehouse/models/BsWh.php
|
Github Open Source
|
Open Source
|
BSD-3-Clause
| 2,018
|
fushikang_docker
|
123343103
|
PHP
|
Code
| 847
| 3,737
|
<?php
namespace app\modules\warehouse\models;
use app\modules\common\models\BsPubdata;
use app\modules\system\models\RUserWhDt;
use Yii;
use app\models\Common;
use app\modules\hr\models\HrStaff;
/**
* This is the model class for table "bs_wh".
*
* @property string $wh_code
* @property string $wh_name
* * @property string $people
* * @property string $company
* @property integer $DISTRICT_ID
* @property string $wh_addr
* @property string $wh_state
* @property string $wh_type
* @property string $wh_lev
* @property string $wh_attr
* @property string $wh_YN
* @property string $remarks
* @property string $OPPER
* @property string $OPP_DATE
* @property string $NWER
* @property string $NW_DATE
* @property string $wh_YNw
* @property BsPart[] $bsParts
* @property BsPrice[] $bsPrices
* @property WhAdm[] $whAdms
*/
class BsWh extends Common
{
/**
* @inheritdoc
*/
public static function tableName()
{
return 'wms.bs_wh';
}
/*
* 获取一条仓库信息
*/
public static function getBsWhInfoOne($id)
{
return self::find()->where(['wh_id' => $id])->one();
}
/*
* 根据仓库名称获取仓库信息
*/
public static function getBsWhInfoByName($name)
{
return self::find()
->select([self::tableName().".wh_code",
self::tableName().".wh_name",
])
->where([
self::tableName().'.wh_name' => $name
])->asArray()->one();
}
/**
* @return \yii\db\Connection the database connection used by this AR class.
*/
public static function getDb()
{
return Yii::$app->get('wms');
}
/**
* @inheritdoc
*/
public function rules()
{
return [
[['wh_code', 'wh_name', 'people','company','wh_state', 'wh_type', 'wh_lev', 'wh_yn', 'yn_deliv','wh_nature'], 'required'],
[['district_id','wh_id'], 'integer'],
[['opp_date', 'nw_date'], 'safe'],
[['wh_code', 'opper', 'nwer','company'], 'string', 'max' => 30],
[['wh_name', 'wh_attr', 'remarks','people'], 'string', 'max' => 200],
[['wh_addr', 'opp_ip'], 'string', 'max' => 20],
// [['wh_type', 'wh_lev', 'wh_yn','wh_nature'], 'int', 'max' => 20],
];
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
return [
'wh_code' => '倉庫代碼',
'wh_name' => '倉庫名稱',
'people' =>'法人,0.请选择1.鸿富锦精密工业(深圳)有限公司2.富泰华工业(深圳)有限公司',
'company' =>'创业公司,0.请选择...1.公司一2.公司二3.公司三',
'district_id' => '倉庫地址代碼.存儲省市區最小的代碼(erp.bs_district)',
'wh_addr' => '倉庫詳情地址',
'wh_state' => '倉庫狀態.Y:有效',
'wh_type' => '倉庫類別,0.其它倉,1.普通倉庫2.恒溫恒濕倉庫3.危化品倉庫4.貴重物品倉庫',
'wh_lev' => '倉庫級別,0.其它,1.一級,2.二級,3.三級',
'wh_attr' => '倉庫屬性.N.外租Y.自有',
'wh_yn' => '是否报废仓:Y.是,N.否',
'yn_deliv' => '是否自提点:Y.是,N.否',
'remarks' => '備注',
'opper' => '操作人',
'opp_date' => '操作時間',
'nwer' => '創建人',
'nw_date' => '創建時間',
'wh_nature' => 'Y.保稅,N非保稅',
'opp_ip' => 'IP地址',
'wh_id' => '倉庫PKID',
];
}
/**
* @return \yii\db\ActiveQuery
*/
public function getBsParts()
{
return $this->hasMany(BsPart::className(), ['wh_code' => 'wh_code']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getBsPrices()
{
return $this->hasMany(BsPrice::className(), ['wh_code' => 'wh_code']);
}
/**
* @return \yii\db\ActiveQuery
*/
public function getWhAdms()
{
return $this->hasOne(WhAdm::className(), ['wh_code' => 'wh_code']);
}
/*
* 下拉列表数据
*/
// public static function options($default=[]){
// //仓库类别
// $list["wh_type"]=[
// '0'=>'其它仓库',
// '1'=>'普通仓库',
// '2'=>'恒温恒湿仓库',
// '3'=>'危化品仓库',
// '4'=>'贵重物品仓库'
// ];
// //状态
// $list["wh_state"]=[
// "Y"=>"有效",
// "N"=>"无效"
// ];
// //仓库级别
// $list["wh_lev"]=[
// "0"=>"其它",
// "1"=>"一级",
// "2"=>"二级",
// "3"=>"三级"
// ];
// //仓库属性
// $list["wh_attr"]=[
// "N"=>"外租",
// "Y"=>"自有"
// ];
// //创业公司
// $list["company"]=[
// "0"=>"请选择",
// "1"=>"公司一",
// "2"=>"公司二 ",
// "3"=>"公司三"
// ];
// //法人
// $list["people"]=[
// "0"=>"请选择",
// "1"=>"鸿富锦精密工业(深圳)有限公司",
// "2"=>"富太华工业(深圳)有限公司"
// ];
// $list["wh_YN"]=[
// "Y"=>"是",
// "N"=>"否"
// ];
// $list["wh_YNw"]=[
// "Y"=>"是",
// "N"=>"否"
// ];
// if(!empty($default)){
// foreach($list as &$item){
// $item=array_merge($default,$item);
// }
// }
// return $list;
// }
public function getWhCode($wh_id)
{
return self::find()->select('wh_code')->where(['wh_id'=>$wh_id])->one();
}
//获取仓库名称
public function getWhName()
{
$list = self::find()->select("wh_name")->groupBy("wh_name")->asArray()->all();
return isset($list) ? $list:[];
}
public static function getWarehouseAll($select='wh_id,wh_code,wh_name'){
return self::find()->select($select)->where(['wh_state'=>'Y'])->asArray()->all();
}
//根據倉庫名稱獲取倉庫代碼
public static function getWareHouse($code)
{
$map = $code;
$child = self::find()->where(['wh_code'=>$map])->select('wh_addr')->one();
return $child;
}
//獲取倉庫名和id
public static function getWhid($select='wh_id,wh_name'){
return self::find()->select($select)->asArray()->all();
}
public static function getTree($wh_id,$user_id)
{
$whdt = RUserWhDt::find()->andWhere(['user_id' => $user_id])->all();
if($wh_id==0) {
$tree = self::find()->andWhere(['wh_state' => 'Y'])->all();
}
else
{
$tree = self::find()->andWhere(['wh_state' => 'Y','wh_id'=>$wh_id])->all();
}
$i = 0;
static $str = "";
$str = $str . "[";
foreach ($tree as $key => $val) {
if ($i == 0) {
$i++;
} else {
$str = $str . ",";
}
$childs = BsPart::find()->where(['wh_code' => $val['wh_code']])->one();
$str .= "
{
\"id\" :\"" . $val['wh_id'] . "\",
\"text\" :\"" . $val['wh_name'] . "<div style='display:none' class='part_id'></div><div style='display:none' class='wh_id'>" . $val['wh_id'] . "</div><div style='display:none' class='level'>1</div>\",
\"level\":\"" . $val['wh_id'] . "\",
\"value\" :\"" . $val['wh_id'] . "\"";
//判断checkbox有没有选中根据id在r_catg表中查询数据
foreach ($whdt as $key1 => $val1) {
if ($val1['wh_pkid'] == $val['wh_id']&!$childs) {
$str .= " ,\"checked\" :true";
}
}
if ($childs) {
$str .= "
, \"children\":";
$str.=self::getTrees($val['wh_code'], $user_id,$val['wh_id'],null);
$str .= "
}";
} else {
$str .= "
}
";
}
}
$str .= "]";
return $str;
}
public static function getTrees($wh_code, $user_id,$wh_id,$part_name)
{
$whdt = RUserWhDt::find()->andWhere(['user_id' => $user_id])->all();
if($part_name==null)
{
$tree = BsPart::find()->andWhere(['wh_code' => $wh_code, 'YN' => 1])->all();
}
else {
$tree = BsPart::find()->andWhere(['wh_code' => $wh_code, 'YN' => 1,'part_name'=>$part_name])->all();
}
$i = 0;
$str = "";
$str = $str . "[";
foreach ($tree as $key => $val) {
if ($i == 0) {
$i++;
} else {
$str = $str . ",";
}
//加1103只是为了区分id,没有其他的意思
$str .= "
{
\"id\" :\"1103" . $val['part_id'] . "\",
\"text\" :\"" . $val['part_name'] . "<div style='display:none' class='part_id'>" . $val['part_id'] . "</div><div style='display:none' class='wh_id'>" . $wh_id . "</div><div style='display:none' class='level'>2</div>\",
\"level\":\"" . $val['part_id'] . "\",
\"value\" :\"" . $val['part_id'] . "\"";
//判断checkbox有没有选中根据id在r_catg表中查询数据
foreach ($whdt as $key1 => $val1) {
if ($val1['part_id'] == $val['part_id']) {
$str .= " ,\"checked\" :true";
}
}
$str .= "}";
}
$str .= "]";
return $str;
}
public static function getList(){
$list = static::find()->select("wh_id,wh_name")->where(['wh_state'=>'Y'])->asArray()->all();
return isset($list) ? $list : [];
}
//仓库属性
public static function getWhAttr(){
return BsPubdata::find()->select("bsp_svalue")->indexBy("bsp_id")->where(['bsp_stype'=>'CKSX'])->asArray()->column();
}
//根据仓库id获取仓库编号和名称
public static function getBsWhcn($wh_id)
{
return self::find()->select('wh_code,wh_name')->where(['wh_id'=>$wh_id])->one();
}
//根据仓库id获取仓库编号和名称
public static function getBsWhname($wh_code)
{
return self::find()->select('wh_name')->where(['wh_code'=>$wh_code])->one();
}
}
| 44,807
|
https://github.com/plehatron/limoncello-bundle/blob/master/Tests/bootstrap.php
|
Github Open Source
|
Open Source
|
Apache-2.0, LicenseRef-scancode-unknown-license-reference
| 2,016
|
limoncello-bundle
|
plehatron
|
PHP
|
Code
| 35
| 112
|
<?php
/** @var \Composer\Autoload\ClassLoader $loader */
if (!($loader = @include __DIR__ . '/../vendor/autoload.php')) {
echo <<<EOT
You need to install the project dependencies using Composer:
composer install --dev
EOT;
exit(1);
}
use Doctrine\Common\Annotations\AnnotationRegistry;
AnnotationRegistry::registerLoader(array($loader, 'loadClass'));
| 45,427
|
https://github.com/bigzoo/spotthetube/blob/master/routes/web.php
|
Github Open Source
|
Open Source
|
MIT
| 2,018
|
spotthetube
|
bigzoo
|
PHP
|
Code
| 35
| 223
|
<?php
/**
* General Routes
*/
Route::get('/', 'HomeController@home')->name('home');
Route::get('about', 'HomeController@about')->name('about');
Route::get('magic', 'MagicController@index')->name('magic');
/**
* Spotify and Youtube Authentication Routes
*/
Route::get('auth/spotify','AuthController@spotifyAuth')->name('spotify.auth');
Route::get('auth/youtube','AuthController@youtubeAuth')->name('youtube.auth');
Route::get('logout', 'AuthController@logout')->name('logout');
/**
* Spotify and Youtube Authentication Callback Routes
*/
Route::get('callback/spotify','AuthController@spotifyCallback')->name('spotify.callback');
Route::get('callback/youtube','AuthController@youtubeCallback')->name('youtube.callback');
| 49,072
|
https://github.com/marcwittke/Backend.Fx/blob/master/src/abstractions/Backend.Fx/BuildingBlocks/Entity.cs
|
Github Open Source
|
Open Source
|
MIT
| 2,021
|
Backend.Fx
|
marcwittke
|
C#
|
Code
| 158
| 442
|
using System;
using System.ComponentModel.DataAnnotations;
using Backend.Fx.Extensions;
using JetBrains.Annotations;
namespace Backend.Fx.BuildingBlocks
{
/// <summary>
/// An object that is not defined by its attributes, but rather by a thread of continuity and its identity.
/// https://en.wikipedia.org/wiki/Domain-driven_design#Building_blocks
/// </summary>
public abstract class Entity : Identified
{
protected Entity()
{
}
protected Entity(int id)
{
Id = id;
}
public DateTime CreatedOn { get; protected set; }
[StringLength(100)] public string CreatedBy { get; protected set; }
public DateTime? ChangedOn { get; protected set; }
[StringLength(100)] public string ChangedBy { get; protected set; }
public void SetCreatedProperties([NotNull] string createdBy, DateTime createdOn)
{
if (createdBy == null)
{
throw new ArgumentNullException(nameof(createdBy));
}
if (createdBy == string.Empty)
{
throw new ArgumentException(nameof(createdBy));
}
CreatedBy = createdBy.Cut(100);
CreatedOn = createdOn;
}
public void SetModifiedProperties([NotNull] string changedBy, DateTime changedOn)
{
if (changedBy == null)
{
throw new ArgumentNullException(nameof(changedBy));
}
if (changedBy == string.Empty)
{
throw new ArgumentException(nameof(changedBy));
}
ChangedBy = changedBy.Cut(100);
ChangedOn = changedOn;
}
}
}
| 42,049
|
https://github.com/joql/blog-admin/blob/master/application/admin/controller/Article.php
|
Github Open Source
|
Open Source
|
Apache-2.0
| null |
blog-admin
|
joql
|
PHP
|
Code
| 644
| 2,872
|
<?php
/**
* Created by PhpStorm.
* User: Joql
* Date: 2018/4/2
* Time: 21:56
*/
namespace app\admin\controller;
use app\model\BlogArticl;
use app\model\BlogArticleTag;
use app\model\BlogCategory;
use app\model\BlogTag;
use app\util\Tools;
use app\util\ReturnCode;
use think\Db;
class Article extends Base
{
/**
* use for: 获取文章列表
* auth: Joql
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\ModelNotFoundException
* @throws \think\exception\DbException
* date:2018-04-04 16:29
*/
public function lists(){
$limit = $this->request->get('size', config('apiAdmin.ADMIN_LIST_DEFAULT'));
$start = $limit * ($this->request->get('page', 1) - 1);
$type = $this->request->get('type', '');
$keywords = $this->request->get('keywords', '');
$status = $this->request->get('status', '');
$where = [];
if ($status === '1' || $status === '0') {
$where['status'] = $status;
}
if ($type) {
switch ($type) {
case 1:
$where['username'] = ['like', "%{$keywords}%"];
break;
case 2:
$where['nickname'] = ['like', "%{$keywords}%"];
break;
}
}
$listInfo = Db::name('articl')
->alias('ba')
->field('ba.aid, ba.title as article_title, ba.author as auth_name, ba.is_show, ba.is_delete, ba.is_top, ba.is_original as is_origin, ba.click, ba.addtime as push_time, ba.cid, bcg.cname as category_name')
->join('blog_category bcg','ba.cid=bcg.cid','left')
->where($where)
->order('addtime', 'DESC')
->limit($start, $limit)->select();
$count = Db::name('articl')->where($where)->count();
//$listInfo = Tools::buildArrFromObj($listInfo);
/*$idArr = array_column($listInfo, 'aid');
$userData = AdminUserData::all(function($query) use ($idArr) {
$query->whereIn('uid', $idArr);
});
$userData = Tools::buildArrFromObj($userData);
$userData = Tools::buildArrByNewKey($userData, 'uid');
$userGroup = AdminAuthGroupAccess::all(function($query) use ($idArr) {
$query->whereIn('uid', $idArr);
});
$userGroup = Tools::buildArrFromObj($userGroup);
$userGroup = Tools::buildArrByNewKey($userGroup, 'uid');*/
foreach ($listInfo as $key => $value) {
$where_tags['aid'] = $value['aid'];
$tags =Db::name('article_tag')
->alias('bat')
->field('bt.tname')
->join('blog_tag bt','bat.tid=bt.tid','left')
->where($where_tags)
->select();
//$tmp = Tools::buildArrFromObj($tags);
$listInfo[$key]['tag_name']='';
foreach ($tags as $v){
$listInfo[$key]['tag_name'] .= $v['tname'].' ';
}
}
return $this->buildSuccess([
'list' => $listInfo,
'count' => $count
]);
}
public function articleInfo(){
$aid = $this->request->get('id');
$where = ['aid'=>$aid];
$info = Db::name('articl')
->field('ba.aid, ba.title as article_title, ba.content as body, ba.description as descr, ba.author as auth_name, ba.keywords as keyw, ba.is_show, ba.is_delete, ba.is_top, ba.is_original as is_origin, ba.click, ba.addtime as push_time, ba.cid, bcg.cname as category_name')
->alias('ba')
->join('blog_category bcg','ba.cid=bcg.cid','left')
->where($where)->find();
//文章内容
$info['body'] = htmlspecialchars_decode($info['body']);
//文章描述
$info['descr'] = htmlspecialchars_decode($info['descr']);
$info['is_top'] = ($info['is_top'] == 1) ? true : false;
$info['is_origin'] = ($info['is_origin'] == 1) ? true : false;
return $this->buildSuccess($info);
}
/**
* use for:原创状态
* auth: Joql
* @return array
* @throws \think\Exception
* @throws \think\exception\PDOException
* date:2018-04-04 17:07
*/
public function changeOriginState(){
$aid = $this->request->get('id');
$state = $this->request->get('status');
$where['aid']=$aid;
$save['is_original'] = $state;
$result = Db::name('articl')->where($where)->update($save);
if($result == 0){
$this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
}
return $this->buildSuccess(['result'=>$result]);
}
/**
* use for: 置顶
* auth: Joql
* @return array
* @throws \think\Exception
* @throws \think\exception\PDOException
* date:2018-04-04 17:08
*/
public function changeTopState(){
$aid = $this->request->get('id');
$state = $this->request->get('status');
$where['aid']=$aid;
$save['is_top'] = $state;
$result = Db::name('articl')->where($where)->update($save);
if($result == 0){
$this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
}
return $this->buildSuccess(['result'=>$result]);
}
/**
* use for:展示
* auth: Joql
* @return array
* @throws \think\Exception
* @throws \think\exception\PDOException
* date:2018-04-04 17:08
*/
public function changeShowState(){
$aid = $this->request->get('id');
$state = $this->request->get('status');
$where['aid']=$aid;
$save['is_show'] = $state;
$result = Db::name('articl')->where($where)->update($save);
if($result == false){
$this->buildFailed(ReturnCode::DB_SAVE_ERROR, '操作失败');
}
return $this->buildSuccess(['result'=>$result]);
}
/**
* use for:保存文章
* auth: Joql
* @return array
* date:2018-04-06 23:51
*/
public function push(){
$ApiAuth = $this->request->header('ApiAuth', '');
$userInfo = cache('Login:' . $ApiAuth);
$userInfo = json_decode($userInfo, true);
$post = $this->request->post();
$aid = $this->request->post('id');
$title = $this->request->post('title');
$body = htmlspecialchars($this->request->post('body'));
$cid = $this->request->post('category_id');
$desc = htmlspecialchars($this->request->post('desc'));
$keyword = $this->request->post('keyw');
$tags = $post['tags'];
$is_show = $this->request->post('is_show');
$is_top = $this->request->post('is_top') == true ? 1:0;
$is_origin = $this->request->post('is_origin') == true ? 1:0;
$save = array(
'title' => $title,
'author' => $userInfo['nickname'],
'content' => $body,
'keywords' => $keyword,
'description'=>$desc,
'is_show' =>$is_show,
'is_top' =>$is_top,
'is_original' =>$is_origin,
'cid' =>$cid
);
if(empty($aid)){
$save['addtime'] = time();
Db::table('blog_articl')->startTrans();
Db::table('blog_articl')->insert($save);
$insert_id = Db::table('blog_articl')->getLastInsID();
if(empty($insert_id)){
Db::name('articl')->rollback();
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR,'文章添加失败');
}
if(!empty($tags)){
$save_category = array();
foreach ($tags as $k=>$v){
$save_category[] = ['aid'=>$insert_id,'tid'=>$v];
}
$insert_cid = Db::table('blog_article_tag')->insertAll($save_category);
if(empty($insert_cid)){
Db::name('articl')->rollback();
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR,'文章目录添加失败');
}
}
Db::name('articl')->commit();
}else{
$where = ['aid'=>$aid];
Db::name('articl')->where($where)->update($save);
if(!empty($tags)){
Db::name('article_tag')->where($where)->delete();
$save_category = array();
foreach ($tags as $k=>$v){
$save_category[] = ['aid'=>$aid,'tid'=>$v];
}
$insert_cid = Db::table('blog_article_tag')->insertAll($save_category);
if(empty($insert_cid)){
return $this->buildFailed(ReturnCode::DB_SAVE_ERROR,'文章目录保存失败',$insert_cid);
}
}
}
return $this->buildSuccess([]);
}
/**
* use for:删除
* auth: Joql
* @return array
* date:2018-04-07 11:10
*/
public function del(){
$aid = $this->request->get('id');
$where = ['aid'=>$aid];
Db::name('articl')->where($where)->delete();
Db::name('article_tag')->where($where)->delete();
return $this->buildSuccess([]);
}
}
| 46,484
|
https://github.com/ahriknow/ahriknow/blob/master/PersonManage/role/apps.py
|
Github Open Source
|
Open Source
|
MIT
| null |
ahriknow
|
ahriknow
|
Python
|
Code
| 9
| 31
|
from django.apps import AppConfig
class RoleConfig(AppConfig):
name = 'PersonManage.role'
| 43,658
|
https://github.com/NREL/SOEP-QSS/blob/master/bin/Linux/Clang/r/GNUmakeinit.mk
|
Github Open Source
|
Open Source
|
BSD-2-Clause
| 2,023
|
SOEP-QSS
|
NREL
|
Makefile
|
Code
| 93
| 383
|
# QSS Make Initialization File
#
# Language: GNU Make
#
# Platform: Linux/Clang/r
# Variables
CXXFLAGS := -pipe -std=c++20 -pedantic -fopenmp=libomp -march=native -Wall -Wextra -Wno-unknown-pragmas -Wimplicit-fallthrough -pthread -fPIC -DNDEBUG -O3 -ffp-model=precise -fno-stack-protector
CXXFLAGS += -Wno-unused-function -Wno-unused-parameter # For FMIL
CXXFLAGS += -Wno-unused-local-typedef # Suppress false-positive warnings
#CXXFLAGS += -DQSS_PROPAGATE_CONTINUOUS # For continuous (x-trajectory) propagation
CFLAGS := -pipe -std=c2x -pedantic -march=native -Wall -Wextra -Wno-unknown-pragmas -Wimplicit-fallthrough -pthread -fPIC -DNDEBUG -O3 -ffp-model=precise -fno-stack-protector
CFLAGS += -Wno-unused-function -Wno-unused-label -Wno-unused-parameter -Wno-unused-but-set-parameter -Wno-unused-variable -Wno-unused-but-set-variable -Wno-sign-compare -Wno-pointer-to-int-cast -Wno-int-to-pointer-cast # For FMIL
LDFLAGS := -pipe -fopenmp=libomp -Wall -s
include $(QSS_bin)/../GNUmakeinit.mk
| 33,678
|
https://github.com/yinyansheng/leetcode/blob/master/src/main/java/com/donne/leetcode/P_14_最长公共前缀.java
|
Github Open Source
|
Open Source
|
MIT
| 2,021
|
leetcode
|
yinyansheng
|
Java
|
Code
| 115
| 324
|
package com.donne.leetcode;
import java.util.Collections;
public class P_14_最长公共前缀 {
public static void main(String[] args) {
System.out.println(longestCommonPrefix(new String[]{"asdf", "asd", "as"}));
}
public static String longestCommonPrefix(String[] strs) {
if (null == strs || 0 == strs.length) {
return "";
}
String lcp = strs[0];
for (int i = 1; i < strs.length; i++) {
lcp = longestCommonPrefix(lcp, strs[i]);
}
return lcp;
}
public static String longestCommonPrefix(String a, String b) {
if (null == a || "".equals(a)) {
return "";
}
if (null == b || "".equals(b)) {
return "";
}
int ptr = 0;
while (ptr < a.length() && ptr < b.length()) {
if (a.charAt(ptr) == b.charAt(ptr)) {
ptr++;
continue;
}
break;
}
return a.substring(0, ptr);
}
}
| 683
|
https://github.com/cryst-al/novoline/blob/master/src/net/Hy.java
|
Github Open Source
|
Open Source
|
Unlicense
| 2,022
|
novoline
|
cryst-al
|
Java
|
Code
| 17
| 50
|
package net;
import com.google.common.collect.HashBasedTable;
public class Hy {
public static HashBasedTable a() {
return HashBasedTable.create();
}
}
| 19,317
|
https://github.com/zero298/morsejs-render-webaudio/blob/master/src/morsejs-render-webaudio.js
|
Github Open Source
|
Open Source
|
MIT
| null |
morsejs-render-webaudio
|
zero298
|
JavaScript
|
Code
| 491
| 1,341
|
/*jslint node:true browser:true */
/*global define, module, AudioContext */
// Support UMD
(function (root, factory) {
"use strict";
/*istanbul ignore next*/
if (typeof define === "function" && define.amd) {
// AMD
define(["morsejs"], factory);
} else if (typeof module === "object" && module.exports) {
// Node but not strict CommonJS
module.exports = factory(require("morsejs"));
} else {
// Browser
root.morsejsRenderWebAudio = factory(root.morsejs);
}
}(this, function (morsejs) {
"use strict";
// Predefine our vars
var exports,
DURATION_LONG,
DURATION_SHORT,
SIGNAL_STRENGTH_OFF,
SIGNAL_STRENGTH_ON;
/**
* Morse code WebAudio rendering module
* @module morsejs-render-webaudio
*/
exports = {};
/**
* The length of time a long signal lasts
* @memberof module:morsejs-render-webaudio
* @constant
* @type {Number}
* @default
*/
DURATION_LONG = 100;
/**
* The length of time a short signal lasts
* @memberof module:morsejs-render-webaudio
* @constant
* @type {Number}
* @default
*/
DURATION_SHORT = 50;
/**
* The frequency of the signal while off
* @memberof module:morsejs-render-webaudio
* @constant
* @type {Number}
* @default
*/
SIGNAL_STRENGTH_OFF = 0;
/**
* The frequency of the signal while on
* @memberof module:morsejs-render-webaudio
* @constant
* @type {Number}
* @default
*/
SIGNAL_STRENGTH_ON = 500;
/**
* Function figure out how long a signal should play
* @memberof module:morsejs-render-webaudio
* @param {Number} signal The signal to find the duration of
* @returns {Number} The duration of the signal given
*/
function getSignalTime(signal) {
var timeDuration = 0;
switch (signal) {
case morsejs.signal.SHORT:
timeDuration = DURATION_SHORT;
break;
default:
timeDuration = DURATION_LONG;
break;
}
return timeDuration;
}
/**
* Function to determine the strength of a signal
* @memberof module:morsejs-render-webaudio
* @param {Number} signal The signal to find the strength of
* @returns {Number} The frequency strength of the signal given
*/
function getSignalStrength(signal) {
var strength = SIGNAL_STRENGTH_OFF;
switch (signal) {
case morsejs.signal.SHORT:
case morsejs.signal.LONG:
strength = SIGNAL_STRENGTH_ON;
break;
default:
break;
}
return strength;
}
/**
* Recursive function to play a message over WebAudio
* @memberof module:morsejs-render-webaudio
* @param {String} message The message to play
* @param {Number} index The index of the signal within the message to play
* @param {OscillatorNode} oscillator The oscilator used to play the message
*/
function transmitMessage(message, index, oscillator) {
var signal = message[index];
oscillator.frequency.value = getSignalStrength(signal);
setTimeout(function () {
if (index < message.length) {
transmitMessage(message, (index + 1), oscillator);
index += 1;
} else {
oscillator.stop();
}
}, getSignalTime(signal));
}
/**
* Function to play a morse message over WebAudio
* @memberof module:morsejs-render-webaudio
* @param {AudioContext} actx The WebAudio context
* @param {String} message The message to play
*/
function playMorse(actx, message) {
var mIndex, osc;
// Set our message index
mIndex = 0;
// Create a sound and start it
osc = actx.createOscillator();
osc.type = "sine";
osc.frequency.value = SIGNAL_STRENGTH_OFF;
osc.connect(actx.destination);
osc.start();
// Start the transmission
transmitMessage(message, mIndex, osc);
}
// Export stuff
exports.DURATION_LONG = DURATION_LONG;
exports.DURATION_SHORT = DURATION_SHORT;
exports.SIGNAL_STRENGTH_OFF = SIGNAL_STRENGTH_OFF;
exports.SIGNAL_STRENGTH_ON = SIGNAL_STRENGTH_ON;
exports.getSignalTime = getSignalTime;
exports.getSignalStrength = getSignalStrength;
exports.transmitMessage = transmitMessage;
exports.playMorse = playMorse;
// Return our module
return exports;
}));
| 1,785
|
https://github.com/smeenai/llvm-project/blob/master/flang/test/Lower/equivalence-static-init.f90
|
Github Open Source
|
Open Source
|
NCSA, LLVM-exception, Apache-2.0
| 2,023
|
llvm-project
|
smeenai
|
Fortran Free Form
|
Code
| 143
| 466
|
! RUN: bbc -emit-fir -o - %s | FileCheck %s
! Test explicit static initialization of equivalence storage
module module_without_init
real :: x(2)
integer :: i(2)
equivalence(i(1), x)
end module
! CHECK-LABEL: fir.global @_QMmodule_without_initEi : !fir.array<8xi8> {
! CHECK: %0 = fir.undefined !fir.array<8xi8>
! CHECK: fir.has_value %0 : !fir.array<8xi8>
! CHECK}
subroutine test_eqv_init
integer, save :: link(3)
integer :: i = 5
integer :: j = 7
equivalence (j, link(1))
equivalence (i, link(3))
end subroutine
! CHECK-LABEL: fir.global internal @_QFtest_eqv_initEi : !fir.array<3xi32> {
! CHECK: %[[VAL_1:.*]] = fir.undefined !fir.array<3xi32>
! CHECK: %[[VAL_2:.*]] = fir.insert_value %0, %c7{{.*}}, [0 : index] : (!fir.array<3xi32>, i32) -> !fir.array<3xi32>
! CHECK: %[[VAL_3:.*]] = fir.insert_value %1, %c0{{.*}}, [1 : index] : (!fir.array<3xi32>, i32) -> !fir.array<3xi32>
! CHECK: %[[VAL_4:.*]] = fir.insert_value %2, %c5{{.*}}, [2 : index] : (!fir.array<3xi32>, i32) -> !fir.array<3xi32>
! CHECK: fir.has_value %[[VAL_4]] : !fir.array<3xi32>
! CHECK: }
| 37,574
|
https://github.com/HowlingShame/Ludum-Date-44-Game/blob/master/Assets/Scripts/Core/MouseCollider.cs
|
Github Open Source
|
Open Source
|
MIT
| null |
Ludum-Date-44-Game
|
HowlingShame
|
C#
|
Code
| 61
| 269
|
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MouseCollider : MonoBehaviour
{
public CircleCollider2D m_Collider;
public Rigidbody2D m_RigidBody;
public const int m_MouseColliderLayer = 31;
public const float m_ColliderRadius = 0.01f;
//////////////////////////////////////////////////////////////////////////
private void Start()
{
gameObject.hideFlags = HideFlags.HideInHierarchy;
gameObject.layer = m_MouseColliderLayer;
m_Collider = gameObject.AddComponent<CircleCollider2D>();
m_Collider.radius = m_ColliderRadius;
m_RigidBody = gameObject.AddComponent<Rigidbody2D>();
m_RigidBody.isKinematic = true;
}
private void LateUpdate()
{
m_RigidBody.MovePosition(Core.Instance.m_MouseWorldPos.m_Position);
}
}
| 2,943
|
https://github.com/rudavko/merchant-center-application-kit/blob/master/packages/mc-scripts/extract-intl.js
|
Github Open Source
|
Open Source
|
MIT
| null |
merchant-center-application-kit
|
rudavko
|
JavaScript
|
Code
| 948
| 2,419
|
/* eslint-disable no-console */
// Do this as the first thing so that any code reading it knows the right env.
process.env.BABEL_ENV = 'development';
process.env.NODE_ENV = 'development';
// Makes the script crash on unhandled rejections instead of silently
// ignoring them. In the future, promise rejections that are not handled will
// terminate the Node.js process with a non-zero exit code.
process.on('unhandledRejection', err => {
throw err;
});
require('shelljs/global');
const fs = require('fs');
const path = require('path');
const mri = require('mri');
const nodeGlob = require('glob');
const { transformAsync } = require('@babel/core');
const getBabelPresetForMcApp = require('@commercetools-frontend/babel-preset-mc-app');
const supportedLocales = ['en', 'de', 'es', 'fr-FR', 'zh-CN', 'ja'];
const flags = mri(process.argv.slice(2), {
alias: { help: ['h'] },
default: {
locale: 'en',
locales: supportedLocales,
'build-translations': false,
},
});
const commands = flags._;
if (commands.length === 0 || (flags.help && commands.length === 0)) {
console.log(`
Usage: mc-scripts extract-intl [options] <glob-pattern>..
Options:
--output-path The location where to put the extracted messages
--locale=<locale> (optional) The default locale to use [default "en"]
--locales=<locale1,locale2,...> (optional) The supported locales to map to [default ${supportedLocales.toString()}]
--build-translations (optional) In case you want to manually build the locale files with the translations [default "false"]
--overwrite-core (optional) By default, if a core.json file exists, existing keys won't be overwritten. This is to ensure that messages in core.json can be updated from external sources. In case you want to avoid this check, you can force writing the extracted messages to core.json [default "false"]
`);
process.exit(0);
}
if (!flags['output-path']) {
throw new Error('Missing required option "--output-path"');
}
const babelConfig = getBabelPresetForMcApp();
const { presets, plugins } = babelConfig;
// Resolve the absolute path of the caller location. This is necessary
// to point to files within that folder.
const rootPath = fs.realpathSync(process.cwd());
const defaultLocale = flags.locale;
const locales = flags.locales;
const outputPath = flags['output-path'];
const shouldBuildTranslations = flags['build-translations'];
const shouldOverwriteWritingToCore = flags['overwrite-core'];
const globFilesToParse = commands[0];
const newLine = () => process.stdout.write('\n');
const task = message => {
process.stdout.write(message);
return error => {
if (error) {
process.stderr.write(error);
}
return newLine();
};
};
// Wrap async functions below into a promise
const glob = pattern =>
new Promise((resolve, reject) => {
nodeGlob(pattern, (error, value) =>
error ? reject(error) : resolve(value)
);
});
// Store existing translations into memory
const coreMessages = {};
const oldLocaleMappings = [];
const localeMappings = [];
// Loop to run once per locale
locales.forEach(locale => {
oldLocaleMappings[locale] = {};
localeMappings[locale] = {};
// File to store translation messages into
const translationFileName = `${outputPath}/${locale}.json`;
try {
// Parse the old translation message JSON files
const messages = JSON.parse(fs.readFileSync(translationFileName));
const messageKeys = Object.keys(messages);
messageKeys.forEach(messageKey => {
oldLocaleMappings[locale][messageKey] = messages[messageKey];
});
} catch (error) {
if (error.code !== 'ENOENT') {
process.stderr.write(
`There was an error loading this translation file: ${translationFileName}
\n${error}`
);
}
}
});
// eslint-disable-next-line global-require
plugins.push([require('babel-plugin-react-intl').default]);
const sortMessages = localeMessages => {
// Sort the translation JSON file so that git diffing is easier
// Otherwise the translation messages will jump around every time we extract
const sortedMessages = {};
Object.keys(localeMessages)
// transform strings to lowercase to imitate phraseapp sorting
.sort((a, b) => a.toLowerCase().localeCompare(b.toLowerCase()))
.forEach(key => {
sortedMessages[key] = localeMessages[key];
});
return sortedMessages;
};
const extractFromFile = async fileName => {
try {
const src = fs.readFileSync(path.join(rootPath, fileName), {
encoding: 'utf8',
});
// Use babel plugin to extract instances where react-intl is used
const { metadata: result } = await transformAsync(src, {
babelrc: false,
presets,
plugins,
filename: fileName,
});
result['react-intl'].messages.forEach(message => {
// Extract core messages
coreMessages[message.id] = message.defaultMessage;
// Extract and map messages for each locale
locales.forEach(locale => {
const oldLocaleMapping = oldLocaleMappings[locale][message.id];
// Merge old translations into the babel extracted instances where react-intl is used
const newMsg = locale === defaultLocale ? message.defaultMessage : '';
localeMappings[locale][message.id] = oldLocaleMapping || newMsg;
});
});
} catch (error) {
process.stderr.write(
`Error transforming file: ${fileName}\n${error.stack}\n\n`
);
}
};
(async function main() {
// Make the directory if it doesn't exist, especially for first run
// eslint-disable-next-line no-undef
mkdir('-p', outputPath);
const memoryTaskDone = task('Storing language files in memory');
const files = (await glob(globFilesToParse)).filter(
// exclude node_modules on non-root-level (due to monorepo-setup)
file =>
!file.match(/node_modules/) &&
!file.match(/dist/) &&
!file.match(/public/)
);
memoryTaskDone();
const extractTaskDone = task('Run extraction on all files');
// Run extraction on all files that match the glob
await Promise.all(files.map(fileName => extractFromFile(fileName)));
extractTaskDone();
const coreTranslationFileName = `${outputPath}/core.json`;
let localeTaskDone = task(
`Writing core translation messages to: ${coreTranslationFileName}`
);
try {
const sortedCoreMessages = sortMessages(coreMessages);
// If a message already exists in the core.json file, we do not overwrite it.
// This is to ensure that core.json messages can be updated from external sources.
let safelyMergedMessages;
if (
!shouldOverwriteWritingToCore &&
fs.existsSync(coreTranslationFileName)
) {
const existingCoreMessages = JSON.parse(
fs.readFileSync(coreTranslationFileName, { encoding: 'utf8' })
);
safelyMergedMessages = Object.keys(sortedCoreMessages).reduce(
(updatedMessages, messageKey) =>
// eslint-disable-next-line
Object.assign({}, updatedMessages, {
[messageKey]:
// If the message key already exists in the core.json file, we won't update it
existingCoreMessages[messageKey] ||
sortedCoreMessages[messageKey],
}),
{}
);
}
// Write to file the JSON representation of the translation messages
const prettified = `${JSON.stringify(
safelyMergedMessages || sortedCoreMessages,
null,
2
)}\n`;
fs.writeFileSync(coreTranslationFileName, prettified, { encoding: 'utf8' });
localeTaskDone();
} catch (error) {
localeTaskDone(
`There was an error saving this translation file: ${coreTranslationFileName}
\n${error}`
);
}
// We usually do not build the translation-files because they are
// handled by transifex and sync by the transifex CLI.
if (shouldBuildTranslations) {
locales.forEach(locale => {
const translationFileName = `${outputPath}/${locale}.json`;
localeTaskDone = task(
`Writing translation messages for ${locale} to: ${translationFileName}\n`
);
try {
const messages = sortMessages(localeMappings[locale]);
// Write to file the JSON representation of the translation messages
const prettified = `${JSON.stringify(messages, null, 2)}`;
fs.writeFileSync(translationFileName, prettified, {
encoding: 'utf8',
});
localeTaskDone();
} catch (error) {
localeTaskDone(
`There was an error saving this translation file: ${translationFileName}
\n${error}`
);
}
});
}
process.exit();
})();
| 19,850
|
https://github.com/CITMProject3/Project3/blob/master/MasterRender.h
|
Github Open Source
|
Open Source
|
MIT
| 2,018
|
Project3
|
CITMProject3
|
C
|
Code
| 341
| 933
|
#ifndef __MASTER_RENDER_H__
#define __MASTER_RENDER_H__
struct DFShader
{
unsigned int id;
unsigned int model, view, projection, shadow_view, shadow_projection;
unsigned int has_texture, texture, shadowmap;
unsigned int Ia, Id, Is;
unsigned int Ka, Kd;
unsigned int L;
unsigned int material_color;
};
struct DFNormalShader
{
unsigned int id;
unsigned int model, view, projection, shadow_view, shadow_projection;
unsigned int texture, normal, shadowmap;
unsigned int Ia, Id, Is;
unsigned int Ka, Kd;
unsigned int L;
unsigned int material_color;
};
struct AnimShader
{
unsigned int id;
unsigned int model, view, projection, shadow_view, shadow_projection;
unsigned int has_texture, texture, shadowmap;
unsigned int Ia, Id, Is;
unsigned int Ka, Kd;
unsigned int L;
unsigned int material_color;
unsigned int bones;
};
struct AnimNormalShader
{
unsigned int id;
unsigned int model, view, projection, shadow_view, shadow_projection;
unsigned int texture, normal, shadowmap;
unsigned int Ia, Id, Is;
unsigned int Ka, Kd;
unsigned int L;
unsigned int material_color;
unsigned int bones;
};
struct TerrainShader
{
unsigned int id;
unsigned int model, view, projection, shadow_view, shadow_projection;
unsigned int Ia, Id;
unsigned int Ka, Kd;
unsigned int L;
unsigned int n_textures;
unsigned int texture_distributor;
unsigned int tex0, tex1, tex2, tex3, shadowmap;
};
struct ShadowShader
{
unsigned int id;
unsigned int projection, view, model;
unsigned int has_anim;
unsigned int bones;
};
struct ParticleShader
{
unsigned int id;
unsigned int view, projection;
unsigned int size;
unsigned int tex;
unsigned int s_color;
unsigned int use_color_time;
unsigned int texture_anim;
unsigned int life_time;
unsigned int tex_anim_data;
};
class GameObject;
class ComponentCamera;
class ComponentMaterial;
struct LightInfo;
class MasterRender
{
public:
MasterRender();
~MasterRender();
void Init();
void RenderDefaultShader(const GameObject* obj, const ComponentCamera* cam, const ComponentMaterial* material,const LightInfo* light)const;
void RenderNormalShader(const GameObject* obj, const ComponentCamera* cam, const ComponentMaterial* material, const LightInfo* light)const;
void RenderAnimShader(const GameObject* obj, const ComponentCamera* cam, const ComponentMaterial* material, const LightInfo* light)const;
void RenderAnimNormalShader(const GameObject* obj, const ComponentCamera* cam, const ComponentMaterial* material, const LightInfo* light)const;
private:
void InitDefaultShader();
void InitDefaultNormalShader();
void InitAnimShader();
void InitAnimNormalShader();
void InitTerrainShader();
void InitShadowShader();
void InitParticleShader();
public:
DFShader df_shader;
DFNormalShader normal_shader;
AnimShader anim_shader;
AnimNormalShader anim_normal_shader;
TerrainShader terrain_shader;
ShadowShader shadow_shader; //Gets rendered in the ShadowMap class
ParticleShader particle_shader;
};
#endif // !__MASTER_RENDER_H__
| 40,860
|
https://github.com/jstastny-cz/appformer/blob/master/uberfire-preferences/uberfire-preferences-api/src/test/java/org/uberfire/preferences/shared/impl/DefaultPreferenceScopesForTests.java
|
Github Open Source
|
Open Source
|
Apache-2.0
| 2,022
|
appformer
|
jstastny-cz
|
Java
|
Code
| 260
| 716
|
/*
* Copyright 2016 Red Hat, Inc. and/or its affiliates.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.uberfire.preferences.shared.impl;
import java.util.Arrays;
import java.util.List;
import org.uberfire.preferences.shared.PreferenceScope;
public class DefaultPreferenceScopesForTests {
public static final String allUsersScopeType = DefaultScopes.ALL_USERS.type();
public static final String entireApplicationScopeType = DefaultScopes.ENTIRE_APPLICATION.type();
public static final String componentScopeType = DefaultScopes.COMPONENT.type();
public static final String userScopeType = DefaultScopes.USER.type();
public static final String allUsersScopeKey = allUsersScopeType;
public static final String entireApplicationScopeKey = entireApplicationScopeType;
public static final String componentScopeKey = "my-component";
public static final String userScopeKey = "my-user";
public static final PreferenceScopeImpl allUsersScope = new PreferenceScopeImpl(allUsersScopeType,
allUsersScopeKey,
null);
public static final PreferenceScopeImpl entireApplicationScope = new PreferenceScopeImpl(entireApplicationScopeType,
entireApplicationScopeKey,
null);
public static final PreferenceScopeImpl componentScope = new PreferenceScopeImpl(componentScopeType,
componentScopeKey,
null);
public static final PreferenceScopeImpl userScope = new PreferenceScopeImpl(userScopeType,
userScopeKey,
null);
public static final PreferenceScopeImpl userComponentScope = new PreferenceScopeImpl(userScopeType,
userScopeKey,
componentScope);
public static final PreferenceScopeImpl userEntireApplicationScope = new PreferenceScopeImpl(userScopeType,
userScopeKey,
entireApplicationScope);
public static final PreferenceScopeImpl allUsersComponentScope = new PreferenceScopeImpl(allUsersScopeType,
allUsersScopeKey,
componentScope);
public static final PreferenceScopeImpl allUsersEntireApplicationScope = new PreferenceScopeImpl(allUsersScopeType,
allUsersScopeKey,
entireApplicationScope);
public static final List<PreferenceScope> defaultOrder = Arrays.asList(userComponentScope,
userEntireApplicationScope,
allUsersComponentScope,
allUsersEntireApplicationScope);
}
| 29,302
|
https://github.com/iseilor/workshop/blob/master/modules/user/views/spouse/form/address.php
|
Github Open Source
|
Open Source
|
BSD-3-Clause
| null |
workshop
|
iseilor
|
PHP
|
Code
| 101
| 484
|
<?php
use yii\helpers\Html;
?>
<div class="form-group">
<?= Html::checkbox('temporary_registered', 0, ['label' => 'Наличие временной регистрации', 'id' => 'temporary_registered', 'style' => 'margin-top: 1rem;',
'checked' => ($model->registration_file) ? true:false]) ?>
</div>
<?= $form->field($model, 'passport_registration')
->textarea([
'readonly' => $model->passport_registration == $user->passport_registration,
'data-user-address-registration' => $user->passport_registration,
])
->hint($model->attributeHints()['passport_registration']) ?>
<?= $form->field($model, 'registration_file_form', [
'options' => ['class' => (!$model->registration_file) ? 'd-none':''],
'template' => getFileInputTemplate($model->registration_file, $model->attributeLabels()['registration_file'] . '.pdf'),
])->fileInput(['class' => 'custom-file-input']) ?>
<?= $form->field($model, 'edj_file_form', [
'options' => ['class' => (!$model->edj_file) ? 'd-none':''],
'template' => getFileInputTemplate($model->edj_file, $model->attributeLabels()['edj_file'] . '.pdf'),
])->fileInput(['class' => 'custom-file-input']) ?>
<?php
$script = <<< JS
$(document).ready(function() {
$('#temporary_registered').on('change', function() {
$('.field-spouse-registration_file_form').toggleClass('d-none');
});
});
JS;
$this->registerJs($script, yii\web\View::POS_READY);
| 25,100
|
https://github.com/MishkaZi/robofriends/blob/master/src/redux/actions.js
|
Github Open Source
|
Open Source
|
MIT
| null |
robofriends
|
MishkaZi
|
JavaScript
|
Code
| 69
| 228
|
import {
CHANGE_SEARCH_FIELD,
REQUEST_ROBOTS_PENDING,
REQUEST_ROBOTS_SUCCESS,
REQUEST_ROBOTS_FAIL,
} from './constants';
import Axios from 'axios';
export const setSearchField = (text) => {
return {
type: CHANGE_SEARCH_FIELD,
payload: text,
};
};
export const requestRobots = () => async (dispatch) => {
dispatch({ type: REQUEST_ROBOTS_PENDING });
try {
const result = await Axios.get(
'https://jsonplaceholder.typicode.com/users'
);
dispatch({ type: REQUEST_ROBOTS_SUCCESS, payload: result.data });
} catch (error) {
dispatch({ type: REQUEST_ROBOTS_FAIL, payload: error });
}
};
| 48,728
|
https://github.com/simon-ritchie/apyscript/blob/master/tests/_geom/test_point2d.py
|
Github Open Source
|
Open Source
|
MIT
| null |
apyscript
|
simon-ritchie
|
Python
|
Code
| 494
| 2,100
|
from random import randint
from retrying import retry
import apysc as ap
from apysc._expression import expression_data_util
from apysc._expression import var_names
from tests.testing_helper import assert_attrs
class TestPoint2D:
@retry(stop_max_attempt_number=15, wait_fixed=randint(10, 3000))
def test___init__(self) -> None:
point: ap.Point2D = ap.Point2D(x=10, y=20)
assert_attrs(
expected_attrs={
'_x': 10,
'_y': 20,
},
any_obj=point)
assert isinstance(point._x, ap.Int)
assert isinstance(point._y, ap.Int)
assert point.variable_name.startswith(f'{var_names.POINT2D}_')
x: ap.Int = ap.Int(10)
y: ap.Int = ap.Int(20)
point = ap.Point2D(x=x, y=y)
assert_attrs(
expected_attrs={
'_x': x,
'_y': y,
},
any_obj=point)
@retry(stop_max_attempt_number=15, wait_fixed=randint(10, 3000))
def test_x(self) -> None:
point: ap.Point2D = ap.Point2D(x=10, y=20)
x: ap.Int = point.x
assert isinstance(x, ap.Int)
assert x == 10
point.x = 20 # type: ignore
assert point.x == 20
@retry(stop_max_attempt_number=15, wait_fixed=randint(10, 3000))
def test_y(self) -> None:
point: ap.Point2D = ap.Point2D(x=10, y=20)
y: ap.Int = point.y
assert isinstance(y, ap.Int)
assert y == 20
point.y = 30 # type: ignore
assert point.y == 30
@retry(stop_max_attempt_number=15, wait_fixed=randint(10, 3000))
def test___eq__(self) -> None:
point: ap.Point2D = ap.Point2D(x=10, y=20)
result: ap.Boolean = point == 20
assert isinstance(result, ap.Boolean)
assert not result
result = point == ap.Point2D(x=10, y=20)
assert isinstance(result, ap.Boolean)
assert result
result = point == ap.Point2D(x=20, y=20)
assert isinstance(result, ap.Boolean)
assert not result
result = point == ap.Point2D(x=10, y=30)
assert not result
@retry(stop_max_attempt_number=15, wait_fixed=randint(10, 3000))
def test___ne__(self) -> None:
point: ap.Point2D = ap.Point2D(x=10, y=20)
result: ap.Boolean = point != ap.Point2D(x=20, y=20)
assert result
result = point != ap.Point2D(x=10, y=20)
assert not result
@retry(stop_max_attempt_number=15, wait_fixed=randint(10, 3000))
def test__append_constructor_expression(self) -> None:
expression_data_util.empty_expression()
x: ap.Int = ap.Int(10)
y: ap.Int = ap.Int(20)
point: ap.Point2D = ap.Point2D(x=x, y=y)
expression: str = expression_data_util.get_current_expression()
expected: str = (
f'{point.variable_name} = '
f'{{"x": {x.variable_name}, "y": {y.variable_name}}};'
)
assert expected in expression
@retry(stop_max_attempt_number=15, wait_fixed=randint(10, 3000))
def test__append_x_getter_expression(self) -> None:
expression_data_util.empty_expression()
point: ap.Point2D = ap.Point2D(x=10, y=20)
x: ap.Int = point.x
expression: str = expression_data_util.get_current_expression()
expected: str = (
f'{x.variable_name} = {point.variable_name}["x"];'
)
assert expected in expression
@retry(stop_max_attempt_number=15, wait_fixed=randint(10, 3000))
def test__append_y_getter_expression(self) -> None:
expression_data_util.empty_expression()
point: ap.Point2D = ap.Point2D(x=10, y=20)
y: ap.Int = point.y
expression: str = expression_data_util.get_current_expression()
expected: str = (
f'{y.variable_name} = {point.variable_name}["y"];'
)
assert expected in expression
@retry(stop_max_attempt_number=15, wait_fixed=randint(10, 3000))
def test__append_x_setter_expression(self) -> None:
expression_data_util.empty_expression()
point: ap.Point2D = ap.Point2D(x=10, y=20)
x: ap.Int = ap.Int(20)
point.x = x
expression: str = expression_data_util.get_current_expression()
expected: str = (
f'{point.variable_name}["x"] = {x.variable_name};'
)
assert expected in expression
@retry(stop_max_attempt_number=15, wait_fixed=randint(10, 3000))
def test__append_y_setter_expression(self) -> None:
expression_data_util.empty_expression()
point: ap.Point2D = ap.Point2D(x=10, y=20)
y: ap.Int = ap.Int(30)
point.y = y
expression: str = expression_data_util.get_current_expression()
expected: str = (
f'{point.variable_name}["y"] = {y.variable_name};'
)
assert expected in expression
@retry(stop_max_attempt_number=15, wait_fixed=randint(10, 3000))
def test__make_snapshot(self) -> None:
point: ap.Point2D = ap.Point2D(x=10, y=20)
snapshot_name: str = point._get_next_snapshot_name()
point._run_all_make_snapshot_methods(snapshot_name=snapshot_name)
assert point._x_snapshots == {snapshot_name: 10}
assert point._y_snapshots == {snapshot_name: 20}
point.x = 30 # type: ignore
point.y = 40 # type: ignore
point._run_all_make_snapshot_methods(snapshot_name=snapshot_name)
assert point._x_snapshots == {snapshot_name: 10}
assert point._y_snapshots == {snapshot_name: 20}
@retry(stop_max_attempt_number=15, wait_fixed=randint(10, 3000))
def test__revert(self) -> None:
point: ap.Point2D = ap.Point2D(x=10, y=20)
snapshot_name: str = point._get_next_snapshot_name()
point._run_all_revert_methods(snapshot_name=snapshot_name)
point._run_all_make_snapshot_methods(snapshot_name=snapshot_name)
point.x = 30 # type: ignore
point.y = 40 # type: ignore
point._run_all_revert_methods(snapshot_name=snapshot_name)
assert point.x == 10
assert point.y == 20
| 6,580
|
https://github.com/orocos-toolchain/typelib/blob/master/typelib/endianness.cc
|
Github Open Source
|
Open Source
|
BSD-3-Clause, CECILL-B, LicenseRef-scancode-unknown-license-reference, LicenseRef-scancode-cecill-b-en
| 2,021
|
typelib
|
orocos-toolchain
|
C++
|
Code
| 527
| 2,202
|
#include "endianness.hh"
#include <iostream>
#include <boost/tuple/tuple.hpp>
#include <boost/lexical_cast.hpp>
namespace Typelib {
size_t const CompileEndianSwapVisitor::FLAG_SKIP;
size_t const CompileEndianSwapVisitor::FLAG_ARRAY;
size_t const CompileEndianSwapVisitor::FLAG_END;
size_t const CompileEndianSwapVisitor::FLAG_SWAP_4;
size_t const CompileEndianSwapVisitor::FLAG_SWAP_8;
size_t const CompileEndianSwapVisitor::SizeOfEnum;
void CompileEndianSwapVisitor::skip(int skip_size)
{
size_t size = m_compiled.size();
if (m_compiled.size() > 1 && m_compiled[size - 2] == FLAG_SKIP)
m_compiled[size - 1] += skip_size;
else
{
m_compiled.push_back(FLAG_SKIP);
m_compiled.push_back(skip_size);
}
}
bool CompileEndianSwapVisitor::visit_ (Numeric const& type)
{
switch(type.getSize())
{
case 1:
skip(1);
return true;
case 2:
m_compiled.push_back(m_output_index + 1);
m_compiled.push_back(m_output_index);
return true;
case 4:
m_compiled.push_back(FLAG_SWAP_4);
return true;
case 8:
m_compiled.push_back(FLAG_SWAP_8);
return true;
default:
throw UnsupportedEndianSwap("objects of size " + boost::lexical_cast<std::string>(type.getSize()));
}
}
bool CompileEndianSwapVisitor::visit_ (Enum const& type)
{
for (int i = SizeOfEnum - 1; i >= 0; --i)
m_compiled.push_back(m_output_index + i);
return true;
}
bool CompileEndianSwapVisitor::visit_ (OpaqueType const& type)
{ throw UnsupportedEndianSwap("opaque"); }
bool CompileEndianSwapVisitor::visit_ (Pointer const& type)
{ throw UnsupportedEndianSwap("pointers"); }
bool CompileEndianSwapVisitor::visit_ (Array const& type)
{
if (type.getIndirection().getCategory() == Type::Array)
{
size_t current_size = m_compiled.size();
visit_(dynamic_cast<Array const&>(type.getIndirection()));
m_compiled[current_size + 1] *= type.getDimension();
return true;
}
m_compiled.push_back(FLAG_ARRAY);
m_compiled.push_back(type.getDimension());
m_compiled.push_back(type.getIndirection().getSize());
size_t current_size = m_compiled.size();
TypeVisitor::visit_(type);
if (m_compiled.size() == current_size + 2 && m_compiled[current_size] == FLAG_SKIP)
{
m_compiled[current_size - 3] = FLAG_SKIP;
m_compiled[current_size - 2] = m_compiled[current_size + 1] * type.getDimension();
m_compiled.pop_back();
m_compiled.pop_back();
m_compiled.pop_back();
}
else
m_compiled.push_back(FLAG_END);
return true;
}
bool CompileEndianSwapVisitor::visit_ (Container const& type)
{ throw UnsupportedEndianSwap("containers"); }
bool CompileEndianSwapVisitor::visit_ (Compound const& type)
{
size_t base_index = m_output_index;
typedef Compound::FieldList Fields;
Fields const& fields(type.getFields());
Fields::const_iterator const end = fields.end();
for (Fields::const_iterator it = fields.begin(); it != end; ++it)
{
size_t new_index = base_index + it->getOffset();
if (new_index < m_output_index)
continue;
else if (new_index > m_output_index)
skip(new_index - m_output_index);
m_output_index = new_index;
dispatch(it->getType());
m_output_index = new_index + it->getType().getSize();
}
return true;
}
void CompileEndianSwapVisitor::apply(Type const& type)
{
m_output_index = 0;
m_compiled.clear();
TypeVisitor::apply(type);
}
std::pair<size_t, std::vector<size_t>::const_iterator>
CompileEndianSwapVisitor::swap(
size_t output_offset, size_t input_offset,
std::vector<size_t>::const_iterator it,
std::vector<size_t>::const_iterator end,
Value in, Value out)
{
uint8_t* input_buffer = reinterpret_cast<uint8_t*>(in.getData());
uint8_t* output_buffer = reinterpret_cast<uint8_t*>(out.getData());
while(it != end)
{
switch(*it)
{
case FLAG_SKIP:
{
size_t skip_size = *(++it);
for (size_t i = 0; i < skip_size; ++i)
{
output_buffer[output_offset] = input_buffer[output_offset];
output_offset++;
}
}
break;
case FLAG_SWAP_4:
{
reinterpret_cast<uint32_t&>(output_buffer[output_offset]) =
Typelib::Endian::swap(reinterpret_cast<uint32_t const&>(input_buffer[output_offset]));
output_offset += 4;
}
break;
case FLAG_SWAP_8:
{
reinterpret_cast<uint64_t&>(output_buffer[output_offset]) =
Typelib::Endian::swap(reinterpret_cast<uint64_t const&>(input_buffer[output_offset]));
output_offset += 8;
}
break;
case FLAG_ARRAY:
{
size_t array_size = *(++it);
size_t element_size = *(++it);
// And swap as many elements as needed
++it;
std::vector<size_t>::const_iterator array_end;
for (size_t i = 0; i < array_size; ++i)
{
boost::tie(output_offset, array_end) =
swap(output_offset, input_offset + element_size * i,
it, end, in, out);
}
it = array_end;
}
break;
case FLAG_END:
return make_pair(output_offset, it);
default:
{
output_buffer[output_offset] = input_buffer[input_offset + *it];
++output_offset;
}
break;
}
++it;
}
return make_pair(output_offset, it);
}
void CompileEndianSwapVisitor::display()
{
std::string indent = "";
std::vector<size_t>::const_iterator it, end;
for (it = m_compiled.begin(); it != m_compiled.end(); ++it)
{
switch(*it)
{
case FLAG_SKIP:
std::cout << std::endl << indent << "SKIP " << *(++it) << std::endl;
break;
case FLAG_ARRAY:
std::cout << std::endl << indent << "ARRAY " << *(++it) << " " << *(++it) << std::endl;
indent += " ";
break;
case FLAG_END:
indent.resize(indent.length() - 2);
std::cout << std::endl << indent << "END" << std::endl;
break;
default:
std::cout << " " << *it;
}
}
}
}
| 45,744
|
https://github.com/sbilly/oui/blob/master/oui-httpd/files/rpc/ubus.lua
|
Github Open Source
|
Open Source
|
MIT
| 2,020
|
oui
|
sbilly
|
Lua
|
Code
| 59
| 144
|
local ubus = require "ubus"
local M = {}
function M.call(params)
local conn = ubus.connect()
if not conn then
error("Failed to connect to ubus")
end
local object = params.object
local method = params.method
if type(object) ~= "string" or type(method) ~= "string" then
error("Invalid argument")
end
local res = conn:call(object, method, params.params or {})
conn:close()
return res
end
return M
| 13,783
|
https://github.com/takuma-yoneda/gym-fetch/blob/master/fetch/mixed_envs/drawer_bin.py
|
Github Open Source
|
Open Source
|
MIT
| 2,022
|
gym-fetch
|
takuma-yoneda
|
Python
|
Code
| 79
| 409
|
import os
from gym import utils
from .. import fetch_env
class DrawerBinEnv(fetch_env.FetchEnv, utils.EzPickle):
def __init__(self, action, reward_type='sparse'):
self.action = action
self.initial_qpos = {
'robot0:slide0': 0.405,
'robot0:slide1': 0.48,
'robot0:slide2': 0.0,
'object0:joint': [1.25, 0.53, 0.4, 1., 0., 0., 0.],
'cabinet:joint': [1.45, 1.1, 1, 1, 0., 0., 0.],
'drawer:slide': 0,
'bin:joint': [1.25, 0.53, 0.4, 1, 0., 0., 0.],
}
fetch_env.FetchEnv.__init__(
self, "drawer_bin.xml",
block_gripper=False, n_substeps=20,
gripper_extra_height=0.2, target_in_the_air=0.5, target_offset=0.0,
obj_range=0.15, target_range=0.15, distance_threshold=0.05,
initial_qpos=self.initial_qpos, reward_type=reward_type,
obj_keys=("bin", "cabinet", "drawer", "object0"),
obs_keys=("bin", "cabinet", "object0"),
goal_key="object0",
)
utils.EzPickle.__init__(self)
| 46,502
|
https://github.com/Dturati/zend2Ionic/blob/master/vendor/zendframework/zend-session/src/SaveHandler/Cache.php
|
Github Open Source
|
Open Source
|
BSD-3-Clause
| 2,018
|
zend2Ionic
|
Dturati
|
PHP
|
Code
| 321
| 902
|
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/
namespace Zend\Session\SaveHandler;
use Zend\Cache\Storage\ClearExpiredInterface as ClearExpiredCacheStorage;
use Zend\Cache\Storage\StorageInterface as CacheStorage;
/**
* Cache session save handler
*/
class Cache implements SaveHandlerInterface
{
/**
* Session Save Path
*
* @var string
*/
protected $sessionSavePath;
/**
* Session Name
*
* @var string
*/
protected $sessionName;
/**
* The cache storage
* @var CacheStorage
*/
protected $cacheStorage;
/**
* Constructor
*
* @param CacheStorage $cacheStorage
*/
public function __construct(CacheStorage $cacheStorage)
{
$this->setCacheStorage($cacheStorage);
}
/**
* Open Session
*
* @param string $savePath
* @param string $name
* @return bool
*/
public function open($savePath, $name)
{
// @todo figure out if we want to use these
$this->sessionSavePath = $savePath;
$this->sessionName = $name;
return true;
}
/**
* Close session
*
* @return bool
*/
public function close()
{
return true;
}
/**
* Read session data
*
* @param string $id
* @return string
*/
public function read($id)
{
return (string) $this->getCacheStorage()->getItem($id);
}
/**
* Write session data
*
* @param string $id
* @param string $data
* @return bool
*/
public function write($id, $data)
{
return $this->getCacheStorage()->setItem($id, $data);
}
/**
* Destroy session
*
* @param string $id
* @return bool
*/
public function destroy($id)
{
return $this->getCacheStorage()->removeItem($id);
}
/**
* Garbage Collection
*
* @param int $maxlifetime
* @return bool
*/
public function gc($maxlifetime)
{
$cache = $this->getCacheStorage();
if ($cache instanceof ClearExpiredCacheStorage) {
return $cache->clearExpired();
}
return true;
}
/**
* Set cache storage
*
* @param CacheStorage $cacheStorage
* @return Cache
*/
public function setCacheStorage(CacheStorage $cacheStorage)
{
$this->cacheStorage = $cacheStorage;
return $this;
}
/**
* Get cache storage
*
* @return CacheStorage
*/
public function getCacheStorage()
{
return $this->cacheStorage;
}
/**
* @deprecated Misspelled method - use getCacheStorage() instead
*/
public function getCacheStorge()
{
return $this->getCacheStorage();
}
}
| 48,897
|
https://github.com/cschen1205/cs-pca/blob/master/project/PCA/PCADimReducer.cs
|
Github Open Source
|
Open Source
|
MIT
| 2,022
|
cs-pca
|
cschen1205
|
C#
|
Code
| 652
| 1,806
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MathNet.Numerics.LinearAlgebra.Generic;
using MathNet.Numerics.LinearAlgebra.Double;
namespace PCA
{
public class PCADimReducer
{
/// <summary>
/// Compress M input data points from original dimension N to new dimension K
/// </summary>
/// <param name="Xinput">M input data points, each having dimension N</param>
/// <param name="K">The new dimension of the data</param>
/// <param name="U_reduce">The MxK matrix, where M is the set of the data set (i.e. M = Xinput.Count), K is the new feature dimension count </param>
/// <param name="variance_retained"></param>
/// <returns></returns>
public List<double[]> CompressData(List<double[]> Xinput, int K, out Matrix<double> U_reduce, out double variance_retained)
{
int dimension = Xinput[0].Length;
int m = Xinput.Count;
int dimension2=dimension-1;
Matrix<double> X = new DenseMatrix(m, dimension2, 0);
for (int i = 0; i < m; ++i)
{
double[] rec = Xinput[i];
for (int d = 1; d < dimension; ++d)
{
X[i, d - 1] = rec[d];
}
}
Matrix<double> X_transpose = X.Transpose();
Matrix<double> Sigma = X_transpose.Multiply(X).Multiply(1.0 / m);
var svd=Sigma.Svd(true);
Matrix<double> U=svd.U();
Vector<double> S = svd.S();
U_reduce = new DenseMatrix(m, K);
for (int i = 0; i < m; ++i)
{
for (int d = 0; d < K; ++d)
{
U_reduce[i, d] = U[i, d];
}
}
double Skk=0;
double Smm=S.Sum();
for(int i=0; i < K; ++i)
{
Skk+=S[i];
}
variance_retained=Skk/Smm;
List<double[]> Zoutput = new List<double[]>();
for (int i = 0; i < m; ++i)
{
double[] rec_x = Xinput[i];
double[] rec_z = new double[K+1];
for (int d = 0; d < K; ++d)
{
double z=0;
for(int d2=0; d2 < dimension2; ++d2)
{
z+=U_reduce[d2, d] * rec_x[d2+1]; //index must start at 1
}
rec_z[d + 1] = z;
}
Zoutput.Add(rec_z);
}
return Zoutput;
}
/// <summary>
/// Reconstruct the K-dimension input Zinput to its original N-dimension form using the compressed matrix U_reduce (obtained from CompressData method)
/// </summary>
/// <param name="Zinput">The K-dimension input data point</param>
/// <param name="U_reduce">The M x K matrix obtained from CompressData method</param>
/// <returns>The reconstructed N-dimension output data point</returns>
public List<double[]> ReconstructData(List<double[]> Zinput, Matrix<double> U_reduce)
{
int m=Zinput.Count;
int K=Zinput[0].Length-1;
Matrix<double> Z = new DenseMatrix(m, K);
for (int i = 0; i < m; ++i)
{
double[] rec_z= Zinput[i];
for(int d=0; d < K; ++d)
{
Z[i, d] = rec_z[d + 1];
}
}
Matrix<double> X = Z.Multiply(U_reduce.Transpose());
int N=X.ColumnCount;
List<double[]> Xoutput = new List<double[]>();
for (int i = 0; i < m; ++i)
{
double[] rec_x = new double[N+1];
for (int d = 0; d < N; ++d)
{
rec_x[d+1] = X[i, d]; //index must start at 1!
}
Xoutput.Add(rec_x);
}
return Xoutput;
}
public List<double[]> CompressData(List<double[]> Xinput, out Matrix<double> U_reduce, out int K, double variance_retained_threshold)
{
int dimension = Xinput[0].Length;
int m = Xinput.Count;
int N = dimension - 1;
Matrix<double> X = new DenseMatrix(m, N, 0);
for (int i = 0; i < m; ++i)
{
double[] rec = Xinput[i];
for (int d = 1; d < dimension; ++d)
{
X[i, d - 1] = rec[d];
}
}
Matrix<double> X_transpose = X.Transpose();
Matrix<double> Sigma = X_transpose.Multiply(X).Multiply(1.0 / m);
var svd = Sigma.Svd(true);
Matrix<double> U = svd.U();
Vector<double> S = svd.S();
double Skk = 0;
double Smm = S.Sum();
K = 0;
for (int i = 0; i < m; ++i)
{
Skk += S[i];
double variance_retained = Skk / Smm;
if (variance_retained >= variance_retained_threshold)
{
K = i;
break;
}
}
U_reduce = new SparseMatrix(m, K);
for (int i = 0; i < m; ++i)
{
for (int d = 0; d < K; ++d)
{
U_reduce[i, d] = U[i, d];
}
}
List<double[]> Zoutput = new List<double[]>();
for (int i = 0; i < m; ++i)
{
double[] rec_x = Xinput[i];
double[] rec_z = new double[K+1];
for (int d = 0; d < K; ++d)
{
double z = 0;
for (int d2 = 0; d2 < N; ++d2)
{
z += U_reduce[d2, d] * rec_x[d2 + 1];
}
rec_z[d + 1] = z;
}
Zoutput.Add(rec_z);
}
return Zoutput;
}
}
}
| 27,641
|
https://github.com/Pragatheesh/mc/blob/master/pkg/console/themes.go
|
Github Open Source
|
Open Source
|
Apache-2.0, LicenseRef-scancode-unknown-license-reference
| 2,015
|
mc
|
Pragatheesh
|
Go
|
Code
| 251
| 968
|
/*
* Minio Client (C) 2015 Minio, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package console
import "github.com/fatih/color"
// MiniTheme - Minio's default color theme
var MiniTheme = Theme{
Debug: (color.New(color.FgWhite, color.Faint, color.Italic)),
Fatal: (color.New(color.FgRed, color.Italic, color.Bold)),
Error: (color.New(color.FgYellow, color.Italic)),
Info: (color.New(color.FgGreen, color.Bold)),
File: (color.New(color.FgWhite)),
Dir: (color.New(color.FgCyan, color.Bold)),
Command: (color.New(color.FgWhite, color.Bold)),
SessionID: (color.New(color.FgYellow, color.Bold)),
Size: (color.New(color.FgYellow)),
Time: (color.New(color.FgGreen)),
JSON: (color.New(color.FgWhite, color.Italic)),
Bar: (color.New(color.FgGreen, color.Bold)),
PrintC: (color.New(color.FgGreen, color.Bold)),
Print: (color.New()),
}
// WhiteTheme - All white color theme
var WhiteTheme = Theme{
Debug: (color.New(color.FgWhite, color.Faint, color.Italic)),
Fatal: (color.New(color.FgWhite, color.Bold, color.Italic)),
Error: (color.New(color.FgWhite, color.Bold, color.Italic)),
Info: (color.New(color.FgWhite, color.Bold)),
File: (color.New(color.FgWhite, color.Bold)),
Dir: (color.New(color.FgWhite, color.Bold)),
Command: (color.New(color.FgWhite, color.Bold)),
SessionID: (color.New(color.FgWhite, color.Bold)),
Size: (color.New(color.FgWhite, color.Bold)),
Time: (color.New(color.FgWhite, color.Bold)),
JSON: (color.New(color.FgWhite, color.Bold, color.Italic)),
Bar: (color.New(color.FgWhite, color.Bold)),
PrintC: (color.New(color.FgWhite, color.Bold)),
Print: (color.New()),
}
// NoColorTheme - Disables color theme
var NoColorTheme = Theme{
Debug: (color.New()),
Fatal: (color.New()),
Error: (color.New()),
Info: (color.New()),
File: (color.New()),
Dir: (color.New()),
Command: (color.New()),
SessionID: (color.New()),
Size: (color.New()),
Time: (color.New()),
JSON: (color.New()),
Bar: (color.New()),
PrintC: (color.New()),
Print: (color.New()),
}
| 16,030
|
https://github.com/alipay/alipay-sdk-net/blob/master/AlipaySDKNet/Response/AlipayOverseasTravelExchangerateBatchqueryResponse.cs
|
Github Open Source
|
Open Source
|
Apache-2.0
| 2,022
|
alipay-sdk-net
|
alipay
|
C#
|
Code
| 71
| 326
|
using System;
using System.Xml.Serialization;
using System.Collections.Generic;
using Aop.Api.Domain;
namespace Aop.Api.Response
{
/// <summary>
/// AlipayOverseasTravelExchangerateBatchqueryResponse.
/// </summary>
public class AlipayOverseasTravelExchangerateBatchqueryResponse : AopResponse
{
/// <summary>
/// 汇率描述
/// </summary>
[XmlElement("rate_desc")]
public string RateDesc { get; set; }
/// <summary>
/// 汇率来源说明
/// </summary>
[XmlElement("rate_source")]
public string RateSource { get; set; }
/// <summary>
/// 多个币种汇率结果,currency:货币代码,ISO标准alpha- 3币种代码; rate:当前币种/CNY的汇率,Number(15,8) currency_icon:货币图片的url地址
/// </summary>
[XmlArray("rates")]
[XmlArrayItem("overseas_travel_rate")]
public List<OverseasTravelRate> Rates { get; set; }
}
}
| 29,393
|
https://github.com/QueenOfSquiggles/the-forgotten-world-ldjam-49/blob/master/.gitignore
|
Github Open Source
|
Open Source
|
MIT
| 2,021
|
the-forgotten-world-ldjam-49
|
QueenOfSquiggles
|
Ignore List
|
Code
| 33
| 110
|
# Godot 4+ specific ignores
.godot/
# Godot-specific ignores
.import/
export.cfg
export_presets.cfg
project.godot
# Imported translations (automatically generated from CSV files)
*.translation
# Mono-specific ignores
.mono/
data_*/
mono_crash.*.json
# my ignores
addons/custom_exports/resource_scripts/
test/
| 39,277
|
https://github.com/kenzya/ds4ui/blob/master/CommunicationLibrary/IPublishingService.cs
|
Github Open Source
|
Open Source
|
MIT
| 2,014
|
ds4ui
|
kenzya
|
C#
|
Code
| 48
| 125
|
using System.ServiceModel;
namespace CommunicationLibrary
{
/// <summary>
/// Interface of the ServiceContract implemented by the service
/// </summary>
[ServiceContract]
public interface IPublishingService
{
/// <summary>
/// Send a new Contract to the subscribed clients
/// </summary>
/// <param name="param">Controller's contract</param>
[OperationContract(IsOneWay = true)]
void PushCommand(ControllerContract param);
}
}
| 1,323
|
https://github.com/OlivierLD/AstroComputer/blob/master/src/test/java/astro/ACTestV1V2.java
|
Github Open Source
|
Open Source
|
Apache-2.0
| null |
AstroComputer
|
OlivierLD
|
Java
|
Code
| 365
| 1,969
|
package astro;
import calc.GeomUtil;
import calc.calculation.AstroComputer;
import calc.calculation.AstroComputerV2;
import calc.calculation.SightReductionUtil;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.TimeZone;
public class ACTestV1V2 {
// This is for tests. Compare V1 & V2
public static void main(String... args) {
SimpleDateFormat SDF_UTC = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss 'UTC'");
// SDF_UTC.setTimeZone(TimeZone.getTimeZone("Etc/UTC"));
System.setProperty("deltaT", "AUTO");
Calendar date = Calendar.getInstance(TimeZone.getTimeZone("Etc/UTC")); // Now
AstroComputer.calculate(
date.get(Calendar.YEAR),
date.get(Calendar.MONTH) + 1,
date.get(Calendar.DAY_OF_MONTH),
date.get(Calendar.HOUR_OF_DAY), // and not just HOUR !!!!
date.get(Calendar.MINUTE),
date.get(Calendar.SECOND));
AstroComputerV2 acV2 = new AstroComputerV2();
acV2.calculate(
date.get(Calendar.YEAR),
date.get(Calendar.MONTH) + 1,
date.get(Calendar.DAY_OF_MONTH),
date.get(Calendar.HOUR_OF_DAY), // and not just HOUR !!!!
date.get(Calendar.MINUTE),
date.get(Calendar.SECOND));
// SF Home
double lat = 37.7489;
double lng = -122.5070;
System.out.println(String.format("\nFrom position %s / %s", GeomUtil.decToSex(lat, GeomUtil.SWING, GeomUtil.NS), GeomUtil.decToSex(lng, GeomUtil.SWING, GeomUtil.EW)));
double sunMeridianPassageTime = AstroComputer.getSunMeridianPassageTime(lat, lng);
System.out.println(String.format("Sun EoT V1: %f", sunMeridianPassageTime));
sunMeridianPassageTime = acV2.getSunMeridianPassageTime(lat, lng);
System.out.println(String.format("Sun EoT V2: %f", sunMeridianPassageTime));
long sunTransit = AstroComputer.getSunTransitTime(lat, lng);
Date tt = new Date(sunTransit);
System.out.println("Transit Time V1:" + tt.toString());
sunTransit = acV2.getSunTransitTime(lat, lng);
tt = new Date(sunTransit);
System.out.println("Transit Time V2:" + tt.toString());
double[] riseAndSet = AstroComputer.sunRiseAndSet(lat, lng);
System.out.println(String.format("V1: Time Rise: %f, Time Set: %f, ZRise: %f, ZSet: %f", riseAndSet[0], riseAndSet[1], riseAndSet[2], riseAndSet[3]));
riseAndSet = acV2.sunRiseAndSet(lat, lng);
System.out.println(String.format("V2: Time Rise: %f, Time Set: %f, ZRise: %f, ZSet: %f", riseAndSet[0], riseAndSet[1], riseAndSet[2], riseAndSet[3]));
System.out.println(String.format("V1 Moon Phase (no specific date, current one) : %f", AstroComputer.getMoonPhase()));
System.out.println(String.format("V2 Moon Phase (no specific date, current one) : %f", acV2.getMoonPhase()));
System.out.println(String.format("V1 Sun data:\nDeclination: %s\nGHA: %s",
GeomUtil.decToSex(AstroComputer.getSunDecl(), GeomUtil.SWING, GeomUtil.NS),
GeomUtil.decToSex(AstroComputer.getSunGHA(), GeomUtil.SWING, GeomUtil.NONE)));
System.out.println(String.format("V2 Sun data:\nDeclination: %s\nGHA: %s",
GeomUtil.decToSex(acV2.getSunDecl(), GeomUtil.SWING, GeomUtil.NS),
GeomUtil.decToSex(acV2.getSunGHA(), GeomUtil.SWING, GeomUtil.NONE)));
SightReductionUtil sru = new SightReductionUtil();
sru.setL(lat);
sru.setG(lng);
sru.setAHG(AstroComputer.getSunGHA());
sru.setD(AstroComputer.getSunDecl());
sru.calculate();
double obsAlt = sru.getHe();
double z = sru.getZ();
System.out.println(String.format("V1 Now: Elev.: %s, Z: %.02f\272", GeomUtil.decToSex(obsAlt, GeomUtil.SWING, GeomUtil.NONE), z));
sru.setAHG(acV2.getSunGHA());
sru.setD(acV2.getSunDecl());
sru.calculate();
obsAlt = sru.getHe();
z = sru.getZ();
System.out.println(String.format("V2 Now: Elev.: %s, Z: %.02f\272", GeomUtil.decToSex(obsAlt, GeomUtil.SWING, GeomUtil.NONE), z));
AstroComputer.EpochAndZ[] epochAndZs = AstroComputer.sunRiseAndSetEpoch(lat, lng);
System.out.println("\nV1 With epochs");
System.out.println(String.format("Rise Date: %s (Z:%.02f\272)\nSet Date: %s (Z:%.02f\272)",
new Date(epochAndZs[0].getEpoch()).toString(),
epochAndZs[0].getZ(),
new Date(epochAndZs[1].getEpoch()).toString(),
epochAndZs[1].getZ()));
AstroComputerV2.EpochAndZ[] epochAndZsV2 = acV2.sunRiseAndSetEpoch(lat, lng);
System.out.println("\nV2 With epochs");
System.out.println(String.format("Rise Date: %s (Z:%.02f\272)\nSet Date: %s (Z:%.02f\272)",
new Date(epochAndZsV2[0].getEpoch()).toString(),
epochAndZsV2[0].getZ(),
new Date(epochAndZsV2[1].getEpoch()).toString(),
epochAndZsV2[1].getZ()));
System.out.println();
double moonTilt = AstroComputer.getMoonTilt(lat, lng);
Calendar calculationDateTime = AstroComputer.getCalculationDateTime();
System.out.println(String.format("At %s, Moon Tilt: %.03f", SDF_UTC.format(calculationDateTime.getTime()), moonTilt));
moonTilt = acV2.getMoonTilt(lat, lng);
calculationDateTime = AstroComputer.getCalculationDateTime();
System.out.println(String.format("At %s, Moon Tilt: %.03f", SDF_UTC.format(calculationDateTime.getTime()), moonTilt));
}
}
| 30,957
|
https://github.com/thecjharries/r-daily-programmer/blob/master/easy/101-200/161/go/main.go
|
Github Open Source
|
Open Source
|
Apache-2.0
| null |
r-daily-programmer
|
thecjharries
|
Go
|
Code
| 385
| 994
|
// Copyright 2021 CJ Harries
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package main
import (
"fmt"
"math/rand"
)
type CardValue int
const (
CardValue2 CardValue = iota + 2
CardValue3
CardValue4
CardValue5
CardValue6
CardValue7
CardValue8
CardValue9
CardValue10
CardValueAce
CardValueJack = CardValue10
CardValueQueen = CardValueJack
CardValueKing = CardValueQueen
)
func (c CardValue) Value() int {
return int(c)
}
var CardValues = []CardValue{CardValueAce, CardValue2, CardValue3, CardValue4, CardValue5, CardValue6, CardValue7, CardValue8, CardValue9, CardValue10, CardValueJack, CardValueQueen, CardValueKing}
type CardSuit int
const (
CardSuitClubs CardSuit = iota
CardSuitDiamonds
CardSuitHearts
CardSuitSpades
)
func (c CardSuit) String() string {
return []string{"clubs", "diamonds", "hearts", "spades"}[c]
}
var CardSuits = []CardSuit{CardSuitClubs, CardSuitDiamonds, CardSuitHearts, CardSuitSpades}
type Card struct {
Value CardValue
Suit CardSuit
}
type Deck []Card
func (d *Deck) Shuffle() {
rand.Shuffle(len(*d), func(i, j int) {
(*d)[i], (*d)[j] = (*d)[j], (*d)[i]
})
}
func (d *Deck) DealBlackjackHand() *BlackjackHand {
hand := new(BlackjackHand)
*hand = append(*hand, (*d)[0], (*d)[1])
*d = (*d)[2:]
return hand
}
func (d *Deck) BlackjackCount() (count int, total int) {
for 0 < len(*d) {
hand := d.DealBlackjackHand()
total++
if hand.IsBlackjack() {
count++
}
}
return
}
func NewDeck(totalDecks int) *Deck {
var deck Deck
for index := 0; index < totalDecks; index++ {
for _, suit := range CardSuits {
for _, value := range CardValues {
card := Card{
Value: value,
Suit: suit,
}
deck = append(deck, card)
}
}
}
return &deck
}
type BlackjackHand []Card
func (h *BlackjackHand) Value() (value int) {
aceCount := -1
for _, card := range *h {
value += card.Value.Value()
if CardValueAce == card.Value {
aceCount++
}
}
if 0 < aceCount {
value -= aceCount * 10
}
return
}
func (h *BlackjackHand) IsBlackjack() bool {
return 2 == len(*h) && 21 == h.Value()
}
var zPrint = fmt.Println
func main() {
_, _ = zPrint("hello world")
}
| 37,646
|
https://github.com/jonechenug/LearningMpaAbp/blob/master/LearningMpaAbp.Web/Models/Tasks/IndexViewModel.cs
|
Github Open Source
|
Open Source
|
MIT
| 2,018
|
LearningMpaAbp
|
jonechenug
|
C#
|
Code
| 131
| 474
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using Abp.Localization;
using LearningMpaAbp.Tasks;
using LearningMpaAbp.Tasks.Dtos;
namespace LearningMpaAbp.Web.Models.Tasks
{
public class IndexViewModel
{
/// <summary>
/// 用来进行绑定列表过滤状态
/// </summary>
public TaskState? SelectedTaskState { get; set; }
/// <summary>
/// 列表展示
/// </summary>
public IReadOnlyList<TaskDto> Tasks { get; }
/// <summary>
/// 创建任务模型
/// </summary>
public CreateTaskInput CreateTaskInput { get; set; }
/// <summary>
/// 更新任务模型
/// </summary>
public UpdateTaskInput UpdateTaskInput { get; set; }
public IndexViewModel(IReadOnlyList<TaskDto> items)
{
Tasks = items;
}
/// <summary>
/// 用于过滤下拉框的绑定
/// </summary>
/// <returns></returns>
public List<SelectListItem> GetTaskStateSelectListItems()
{
var list=new List<SelectListItem>()
{
new SelectListItem()
{
Text = "AllTasks",
Value = "",
Selected = SelectedTaskState==null
}
};
list.AddRange(Enum.GetValues(typeof(TaskState))
.Cast<TaskState>()
.Select(state=>new SelectListItem()
{
Text = $"TaskState_{state}",
Value = state.ToString(),
Selected = state==SelectedTaskState
})
);
return list;
}
}
}
| 23,318
|
https://github.com/jlec/relax/blob/master/extern/numdifftools/core.py
|
Github Open Source
|
Open Source
|
BSD-3-Clause
| 2,015
|
relax
|
jlec
|
Python
|
Code
| 4,337
| 12,225
|
"""
Numdifftools implementation
"""
#-------------------------------------------------------------------------
#Author: Per A. Brodtkorb
#
# Created: 01.08.2008
# Copyright: (c) pab 2008
# Licence: New BSD
#
# Based on matlab functions derivest.m gradest.m hessdiag.m, hessian.m
# and jacobianest.m by:
#
# Author: John D'Errico
# e-mail: woodchips@rochester.rr.com
# Release: 1.0
# Release date: 12/27/2006
#-------------------------------------------------------------------------
#!/usr/bin/env python
from __future__ import division
import numpy as np
import scipy.linalg as linalg
#import numpy.linalg as linalg
import scipy.misc as misc
import warnings
__all__ = [
'dea3', 'Derivative', 'Jacobian', 'Gradient', 'Hessian', 'Hessdiag'
]
_TINY = np.finfo(float).tiny
_EPS = np.finfo(float).eps
def dea3(v0, v1, v2):
'''
Extrapolate a slowly convergent sequence
Parameters
----------
v0, v1, v2 : array-like
3 values of a convergent sequence to extrapolate
Returns
-------
result : array-like
extrapolated value
abserr : array-like
absolute error estimate
Description
-----------
DEA3 attempts to extrapolate nonlinearly to a better estimate
of the sequence's limiting value, thus improving the rate of
convergence. The routine is based on the epsilon algorithm of
P. Wynn, see [1]_.
Example
-------
# integrate sin(x) from 0 to pi/2
>>> import numpy as np
>>> import numdifftools as nd
>>> Ei= np.zeros(3)
>>> linfun = lambda k : np.linspace(0,np.pi/2.,2.**(k+5)+1)
>>> for k in np.arange(3):
... x = linfun(k)
... Ei[k] = np.trapz(np.sin(x),x)
>>> [En, err] = nd.dea3(Ei[0], Ei[1], Ei[2])
>>> truErr = Ei-1.
>>> (truErr, err, En)
(array([ -2.00805680e-04, -5.01999079e-05, -1.25498825e-05]), array([ 0.00020081]), array([ 1.]))
See also
--------
dea
Reference
---------
.. [1] C. Brezinski (1977)
"Acceleration de la convergence en analyse numerique",
"Lecture Notes in Math.", vol. 584,
Springer-Verlag, New York, 1977.
'''
E0, E1, E2 = np.atleast_1d(v0, v1, v2)
abs = np.abs #@ReservedAssignment
max = np.maximum #@ReservedAssignment
delta2, delta1 = E2 - E1, E1 - E0
err2, err1 = abs(delta2), abs(delta1)
tol2, tol1 = max(abs(E2), abs(E1)) * _EPS, max(abs(E1), abs(E0)) * _EPS
with warnings.catch_warnings():
warnings.simplefilter("ignore") # ignore division by zero and overflow
ss = 1.0 / delta2 - 1.0 / delta1
smallE2 = (abs(ss * E1) <= 1.0e-3).ravel()
result = 1.0 * E2
abserr = err1 + err2 + E2 * _EPS * 10.0
converged = (err1 <= tol1) & (err2 <= tol2).ravel() | smallE2
k4, = (1 - converged).nonzero()
if k4.size > 0 :
result[k4] = E1[k4] + 1.0 / ss[k4]
abserr[k4] = err1[k4] + err2[k4] + abs(result[k4] - E2[k4])
return result, abserr
def vec2mat(vec, n, m):
''' forms the matrix M, such that M(i,j) = vec(i+j)
'''
[i, j] = np.ogrid[0:n, 0:m]
return np.matrix(vec[i + j])
class _Derivative(object):
''' Object holding common variables and methods for the numdifftools
Parameters
----------
fun : callable
function to differentiate.
n : Integer from 1 to 4 (Default 1)
defining derivative order.
order : Integer from 1 to 4 (Default 2)
defining order of basic method used.
For 'central' methods, it must be from the set [2,4].
method : Method of estimation. Valid options are:
'central', 'forward' or 'backward'. (Default 'central')
romberg_terms : integer from 0 to 3 (Default 2)
Number of Romberg terms used in the extrapolation.
Note: 0 disables the Romberg step completely.
step_max : real scalar (Default 2.0)
Maximum allowed excursion from step_nom as a multiple of it.
step_nom : real scalar default maximum(log2(abs(x0)), 0.02)
Nominal step.
step_ratio: real scalar (Default 2.0)
Ratio used between sequential steps in the estimation of the derivative
step_num : integer, default 26
The minimum step_num is
7 + np.ceil(self.n/2.) + self.order + self.romberg_terms
The steps: h_i = step_nom[i]*step_max*step_ratio**(-arange(steps_num))
vectorized : Bool
True - if your function is vectorized.
False - loop over the successive function calls (default).
Uses a semi-adaptive scheme to provide the best estimate of the
derivative by its automatic choice of a differencing interval. It uses
finite difference approximations of various orders, coupled with a
generalized (multiple term) Romberg extrapolation. This also yields the
error estimate provided. See the document DERIVEST.pdf for more explanation
of the algorithms behind the parameters.
Note on order: higher order methods will generally be more accurate,
but may also suffer more from numerical problems. First order
methods would usually not be recommended.
Note on method: Central difference methods are usually the most accurate,
but sometimes one can only allow evaluation in forward or backward
direction.
'''
def __init__(self, fun, n=1, order=2, method='central', romberg_terms=2,
step_max=2.0, step_nom=None, step_ratio=2.0, step_num=26,
vectorized=False, verbose=False):
self.fun = fun
self.n = n
self.order = order
self.method = method
self.romberg_terms = romberg_terms
self.step_max = step_max
self.step_ratio = step_ratio
self.step_nom = step_nom
self.step_num = step_num
self.vectorized = vectorized
self.verbose = verbose
self._check_params()
self.error_estimate = None
self.finaldelta = None
# The remaining member variables are set by _initialize
self._fda_rule = None
self._delta = None
self._rmat = None
self._qromb = None
self._rromb = None
self._fdiff = None
def _check_params(self):
''' check the parameters for acceptability
'''
atleast_1d = np.atleast_1d
kwds = self.__dict__
for name in ['n', 'order']:
val = np.atleast_1d(kwds[name])
if ((len(val) != 1) or (not val in (1, 2, 3, 4))):
raise ValueError('%s must be scalar, one of [1 2 3 4].' % name)
name = 'romberg_terms'
val = atleast_1d(kwds[name])
if ((len(val) != 1) or (not val in (0, 1, 2, 3))):
raise ValueError('%s must be scalar, one of [0 1 2 3].' % name)
for name in ('step_max', 'step_num'):
val = kwds[name]
if (val != None and ((len(atleast_1d(val)) > 1) or (val <= 0))):
raise ValueError('%s must be None or a scalar, >0.' % name)
validMethods = dict(c='central', f='forward', b='backward')
method = validMethods.get(kwds['method'][0])
if method == None :
t = 'Invalid method: Must start with one of c, f, b characters!'
raise ValueError(t)
if method[0] == 'c' and kwds['method'] in (1, 3):
t = 'order 1 or 3 is not possible for central difference methods'
raise ValueError(t)
def _initialize(self):
'''Set derivative parameters:
stepsize, differention rule and romberg extrapolation matrices
'''
self._set_delta()
self._set_fda_rule()
self._set_romb_qr()
self._set_difference_function()
def _fder(self, fun, f_x0i, x0i, h):
'''
Return derivative estimates of f at x0 for a sequence of stepsizes h
Member variables used
---------------------
n
_fda_rule
romberg_terms
'''
fdarule = self._fda_rule
nfda = fdarule.size
ndel = h.size
f_del = self._fdiff(fun, f_x0i, x0i, h)
if f_del.size != h.size:
t = 'fun did not return data of correct size (it must be vectorized)'
raise ValueError(t)
ne = max(ndel + 1 - nfda - self.romberg_terms, 1)
der_init = np.asarray(vec2mat(f_del, ne, nfda) * fdarule.T)
der_init = der_init.ravel() / (h[0:ne]) ** self.n
return der_init, h[0:ne]
def _trim_estimates(self, der_romb, errors, h):
'''
trim off the estimates at each end of the scale
'''
trimdelta = h.copy()
der_romb = np.atleast_1d(der_romb)
num_vals = len(der_romb)
nr_rem_min = int((num_vals-1)/2)
nr_rem = min(2 * max((self.n - 1), 1), nr_rem_min)
if nr_rem>0:
tags = der_romb.argsort()
tags = tags[nr_rem:-nr_rem]
der_romb = der_romb[tags]
errors = errors[tags]
trimdelta = trimdelta[tags]
return der_romb, errors, trimdelta
def _plot_errors(self, h2, errors, stepNom_i, der_romb ):
print('Stepsize, Value, Errors')
print((np.vstack((h2, der_romb, errors)).T))
import matplotlib.pyplot as plt
plt.ioff()
plt.subplot(2, 1, 1)
try:
#plt.loglog(h2,der_romb, h2, der_romb+errors,'r--',h2, der_romb-errors,'r--')
plt.loglog(h2, der_romb-der_romb.min() + _EPS,
h2, der_romb-der_romb.min() + _EPS, '.') #, h2, +errors,'r--',h2, -errors,'r--')
small = 2 * np.sqrt(_EPS) ** (1. / np.sqrt(self.n))
plt.vlines(small, 1e-15, 1)
plt.title('Absolute error as function of stepsize nom=%g' % stepNom_i)
plt.subplot(2, 1, 2)
plt.loglog(h2, errors, 'r--', h2, errors, 'r.')
plt.vlines(small, 1e-15, 1)
plt.show()
except:
pass
def _derivative(self, fun, x00, stepNom=None):
x0 = np.atleast_1d(x00)
if stepNom is None:
stepNom = np.maximum(np.log2(np.abs(x0)), 0.02)
else:
stepNom = np.atleast_1d(stepNom)
# was a single point supplied?
nx0 = x0.shape
n = x0.size
f_x0 = np.zeros(nx0)
# will we need fun(x0)?
evenOrder = (np.remainder(self.n, 2) == 0)
if evenOrder or not self.method[0] == 'c':
if self.vectorized:
f_x0 = fun(x0)
else:
f_x0 = np.asfarray([fun(x0j) for x0j in x0])
der = np.zeros(nx0)
errest = np.zeros(nx0)
finaldelta = np.zeros(nx0)
delta = self._delta
for i in range(n):
f_x0i = float(f_x0[i])
x0i = float(x0[i])
h = (1.0 * stepNom[i]) * delta
der_init, h1 = self._fder(fun, f_x0i, x0i, h)
der_romb, errors, h2 = self._romb_extrap(der_init, h1)
if self.verbose:
self._plot_errors(h2, errors, stepNom[i], der_romb )
der_romb, errors, h2 = self._trim_estimates(der_romb, errors, h2)
ind = errors.argmin()
errest[i] = errors[ind]
finaldelta[i] = h2[ind]
der[i] = der_romb[ind]
self.error_estimate = errest
self.finaldelta = finaldelta
return der
def _fda_mat(self, parity, nterms):
''' Return matrix for fda derivation.
Parameters
----------
parity : scalar, integer
0 (one sided, all terms included but zeroth order)
1 (only odd terms included)
2 (only even terms included)
nterms : scalar, integer
number of terms
Member variables used
---------------------
step_ratio
'''
srinv = 1.0 / self.step_ratio
factorial = misc.factorial
arange = np.arange
[i, j] = np.ogrid[0:nterms, 0:nterms]
if parity == 0:
c = 1.0 / factorial(arange(1, nterms + 1))
mat = c[j] * srinv ** (i * (j + 1))
elif parity == 1 or parity == 2:
c = 1.0 / factorial(arange(parity, 2 * nterms + 1, 2))
mat = c[j] * srinv ** (i * (2 * j + parity))
return np.matrix(mat)
def _set_fda_rule(self):
'''
Generate finite differencing rule in advance.
The rule is for a nominal unit step size, and will
be scaled later to reflect the local step size.
Member methods used
-------------------
_fda_mat
Member variables used
---------------------
n
order
method
'''
der_order = self.n
met_order = self.order
method = self.method[0]
matrix = np.matrix
zeros = np.zeros
fda_rule = matrix(der_order)
pinv = linalg.pinv
if method == 'c' : #'central'
if met_order == 2:
if der_order == 3:
fda_rule = matrix([0, 1]) * pinv(self._fda_mat(1, 2))
elif der_order == 4:
fda_rule = matrix([0, 1]) * pinv(self._fda_mat(2, 2))
elif der_order == 1:
fda_rule = matrix([1, 0]) * pinv(self._fda_mat(1, 2))
elif der_order == 2:
fda_rule = matrix([1, 0]) * pinv(self._fda_mat(2, 2))
elif der_order == 3:
fda_rule = matrix([0, 1, 0]) * pinv(self._fda_mat(1, 3))
elif der_order == 4:
fda_rule = matrix([0, 1, 0]) * pinv(self._fda_mat(2, 3))
else:
if met_order == 1:
if der_order != 1:
v = zeros(der_order)
v[der_order - 1] = 1
fda_rule = matrix(v) * pinv(self._fda_mat(0, der_order))
else:
v = zeros(der_order + met_order - 1)
v[der_order - 1] = 1
dpm = der_order + met_order - 1
fda_rule = matrix(v) * pinv(self._fda_mat(0, dpm))
if method == 'b': # 'backward' rule
fda_rule = -fda_rule
self._fda_rule = fda_rule.ravel()
def _get_min_num_steps(self):
n0 = 5 if self.method[0] == 'c' else 7
return int(n0 + np.ceil(self.n / 2.) + self.order + self.romberg_terms)
def _set_delta(self):
''' Set the steps to use in derivation.
Member variables used:
n
order
method
romberg_terms
step_max
'''
# Choose the step size h so that it is an exactly representable number.
# This is important when calculating numerical derivatives and is
# accomplished by the following.
step_ratio = float(self.step_ratio + 1.0) - 1.0
if self.step_num is None:
num_steps = self._get_min_num_steps()
else:
num_steps = max(self.step_num, 1)
step1 = float(self.step_max + 1.0) - 1.0
self._delta = step1 * step_ratio ** (-np.arange(num_steps))
#hn^N<sqrt(eps)
def _set_romb_qr(self):
'''
Member variables used
order
method
romberg_terms
'''
nexpon = self.romberg_terms
add1 = self.method[0] == 'c'
rombexpon = (1 + add1) * np.arange(nexpon) + self.order
srinv = 1.0 / self.step_ratio
# do nothing if no romberg terms
rmat = np.ones((nexpon + 2, nexpon + 1))
if nexpon > 0:
rmat[1, 1:] = srinv ** rombexpon
for n in range(2, nexpon + 2):
rmat[n, 1:] = srinv ** (n * rombexpon)
rmat = np.matrix(rmat)
# qr factorization used for the extrapolation as well
# as the uncertainty estimates
self._qromb, self._rromb = linalg.qr(rmat)
self._rmat = rmat
def _set_difference_function(self):
''' Set _fdiff function according to method
'''
get_diff_fun = dict(c=self._central, b=self._backward, f=self._forward)[self.method[0]]
self._fdiff = get_diff_fun()
def _central(self):
''' Return central difference function
Member variables used
n
fun
vectorized
'''
# A central rule, so we will need to evaluate
# symmetrically around x0i.
evenOrder = (np.remainder(self.n, 2) == 0)
if self.vectorized:
if evenOrder:
f_del = lambda fun, f_x0i, x0i, h: (fun(x0i + h) + fun(x0i - h)).ravel()/2.0 - f_x0i
else:
f_del = lambda fun, f_x0i, x0i, h: (fun(x0i + h) - fun(x0i - h)).ravel()/2.0
else:
if evenOrder:
f_del = lambda fun, f_x0i, x0i, h: np.asfarray([fun(x0i + h_j) + fun(x0i - h_j) for h_j in h]).ravel()/2.0 - f_x0i
else:
f_del = lambda fun, f_x0i, x0i, h: np.asfarray([fun(x0i + h_j) - fun(x0i - h_j) for h_j in h]).ravel()/2.0
return f_del
def _forward(self):
''' Return forward difference function
Member variables used
fun
vectorized
'''
# drop off the constant only
if self.vectorized:
f_del = lambda fun, f_x0i, x0i, h: (fun(x0i + h) - f_x0i).ravel()
else:
f_del = lambda fun, f_x0i, x0i, h: np.asfarray([fun(x0i + h_j) - f_x0i for h_j in h]).ravel()
return f_del
def _backward(self):
''' Return backward difference function
Member variables used
---------------------
fun
vectorized
'''
if self.vectorized:
f_del = lambda fun, f_x0i, x0i, h: (fun(x0i - h) - f_x0i).ravel()
else:
f_del = lambda fun, f_x0i, x0i, h: np.asfarray([fun(x0i - h_j) - f_x0i for h_j in h]).ravel()
return f_del
def _remove_non_finite(self, der_init, h1):
isnonfinite = 1 - np.isfinite(der_init)
i_nonfinite, = isnonfinite.ravel().nonzero()
hout = h1
if i_nonfinite.size > 0:
allfinite_start = np.max(i_nonfinite) + 1
der_init = der_init[allfinite_start:]
hout = h1[allfinite_start:]
return der_init, hout
def _predict_uncertainty(self, rombcoefs, rhs):
'''uncertainty estimate of derivative prediction'''
sqrt = np.sqrt
asarray = np.asarray
s = sqrt(np.sum(asarray(rhs - self._rmat * rombcoefs[0]) ** 2, axis=0))
rinv = asarray(linalg.pinv(self._rromb))
cov1 = np.sum(rinv ** 2, axis=1) # 1 spare dof
errest = np.maximum(s * 12.7062047361747 * sqrt(cov1[0]), s * _EPS * 10.)
errest = np.where(s == 0, _EPS, errest)
return errest
def _romb_extrap(self, der_init, h1):
''' Return Romberg extrapolated derivatives and error estimates
based on the initial derivative estimates
Parameter
---------
der_init - initial derivative estimates
h1 - stepsizes used in the derivative estimates
Returns
-------
der_romb - derivative estimates returned
errest - error estimates
hout - stepsizes returned
Member variables used
---------------------
step_ratio - Ratio decrease in step
rombexpon - higher order terms to cancel using the romberg step
'''
# amp = linalg.cond(self._rromb)
# amp - noise amplification factor due to the romberg step
# the noise amplification is further amplified by the Romberg step.
der_romb, hout = self._remove_non_finite(der_init, h1)
# this does the extrapolation to a zero step size.
nexpon = self.romberg_terms
ne = der_romb.size
if ne < nexpon+2:
errest = np.ones(der_init.shape) * hout
else:
rhs = vec2mat(der_romb, nexpon + 2, max(1, ne - (nexpon + 2)))
rombcoefs = linalg.lstsq(self._rromb, (self._qromb.T * rhs))
der_romb = rombcoefs[0][0,:]
hout = hout[:der_romb.size]
errest = self._predict_uncertainty(rombcoefs, rhs)
if der_romb.size > 2:
der_romb, err_dea = dea3(der_romb[0:-2], der_romb[1:-1],
der_romb[2:])
errest = np.maximum(errest[2:], err_dea)
hout = hout[2:]
return der_romb, errest, hout
class _PartialDerivative(_Derivative):
def _partial_der(self, x00):
''' Return partial derivatives
'''
x0 = np.atleast_1d(x00)
nx = len(x0)
PD = np.zeros(nx)
err = np.zeros(nx)
finaldelta = np.zeros(nx)
stepNom = [None,]*nx if self.step_nom is None else self.step_nom
fun = self._fun
self._x = np.asarray(x0, dtype=float)
for ind in range(nx):
self._ix = ind
PD[ind] = self._derivative(fun, x0[ind], stepNom[ind])
err[ind] = self.error_estimate
finaldelta[ind] = self.finaldelta
self.error_estimate = err
self.finaldelta = finaldelta
return PD
def _fun(self, xi):
x = self._x.copy()
x[self._ix] = xi
return self.fun(x)
class Derivative(_Derivative):
__doc__ = ( #@ReservedAssignment
'''Estimate n'th derivative of fun at x0, with error estimate
''' + _Derivative.__doc__.partition('\n')[2] + '''
Examples
--------
>>> import numpy as np
>>> import numdifftools as nd
# 1'st and 2'nd derivative of exp(x), at x == 1
>>> fd = nd.Derivative(np.exp) # 1'st derivative
>>> fdd = nd.Derivative(np.exp,n=2) # 2'nd derivative
>>> fd(1)
array([ 2.71828183])
>>> d2 = fdd([1, 2])
>>> d2
array([ 2.71828183, 7.3890561 ])
>>> np.abs(d2-np.exp([1,2]))< fdd.error_estimate # Check error estimate
array([ True, True], dtype=bool)
# 3'rd derivative of x.^3+x.^4, at x = [0,1]
>>> fun = lambda x: x**3 + x**4
>>> dfun = lambda x: 6 + 4*3*2*np.asarray(x)
>>> fd3 = nd.Derivative(fun,n=3)
>>> fd3([0,1]) # True derivatives: [6,30]
array([ 6., 30.])
>>> np.abs(fd3([0,1])-dfun([0,1])) <= fd3.error_estimate
array([ True, True], dtype=bool)
See also
--------
Gradient,
Hessdiag,
Hessian,
Jacobian
''')
def __call__(self, x00):
return self.derivative(x00)
def derivative(self, x0):
''' Return estimate of n'th derivative of fun at x0
using romberg extrapolation
'''
self._initialize()
x00 = np.atleast_1d(x0)
shape = x00.shape
tmp = self._derivative(self.fun, x00.ravel(), self.step_nom)
return tmp.reshape(shape)
class Jacobian(_Derivative):
_jacob_txt = _Derivative.__doc__.partition('\n')[2].replace(
'Integer from 1 to 4 defining derivative order. (Default 1)',
'Derivative order is always 1')
__doc__ = ( #@ReservedAssignment
'''Estimate Jacobian matrix, with error estimate
''' + _jacob_txt + '''
The Jacobian matrix is the matrix of all first-order partial derivatives
of a vector-valued function.
Assumptions
-----------
fun : (vector valued)
analytical function to differentiate.
fun must be a function of the vector or array x0.
x0 : vector location at which to differentiate fun
If x0 is an N x M array, then fun is assumed to be
a function of N*M variables.
Examples
--------
>>> import numpy as np
>>> import numdifftools as nd
#(nonlinear least squares)
>>> xdata = np.reshape(np.arange(0,1,0.1),(-1,1))
>>> ydata = 1+2*np.exp(0.75*xdata)
>>> fun = lambda c: (c[0]+c[1]*np.exp(c[2]*xdata) - ydata)**2
>>> Jfun = nd.Jacobian(fun)
>>> h = Jfun([1., 2., 0.75]) # should be numerically zero
>>> np.abs(h) < 1e-14
array([[ True, True, True],
[ True, True, True],
[ True, True, True],
[ True, True, True],
[ True, True, True],
[ True, True, True],
[ True, True, True],
[ True, True, True],
[ True, True, True],
[ True, True, True]], dtype=bool)
>>> np.abs(h) <= 2 * Jfun.error_estimate
array([[ True, True, True],
[ True, True, True],
[ True, True, True],
[ True, True, True],
[ True, True, True],
[ True, True, True],
[ True, True, True],
[ True, True, True],
[ True, True, True],
[ True, False, True]], dtype=bool)
See also
--------
Gradient,
Derivative,
Hessdiag,
Hessian
''')
def __call__(self, x00):
return self.jacobian(x00)
def jacobian(self, x00):
'''
Return Jacobian matrix of a vector valued function of n variables
Parameter
---------
x0 : vector
location at which to differentiate fun.
If x0 is an nxm array, then fun is assumed to be
a function of n*m variables.
Member variable used
--------------------
fun : (vector valued) analytical function to differentiate.
fun must be a function of the vector or array x0.
Returns
-------
jac : array-like
first partial derivatives of fun. Assuming that x0
is a vector of length p and fun returns a vector
of length n, then jac will be an array of size (n,p)
err - vector
of error estimates corresponding to each partial
derivative in jac.
See also
--------
Derivative,
Gradient,
Hessian,
Hessdiag
'''
self.n = 1
fun = self.fun
self._initialize()
zeros = np.zeros
newaxis = np.newaxis
x0 = np.atleast_1d(x00)
nx = x0.size
f0 = fun(x0)
f0 = f0.ravel()
n = f0.size
jac = zeros((n, nx))
if n == 0 :
self.error_estimate = jac
return jac
delta = self._delta
nsteps = delta.size
if self.step_nom == None :
stepNom = np.maximum(np.abs(x0), 0.02)
else:
stepNom = self.step_nom
err = jac.copy()
finaldelta = jac.copy()
for i in range(nx):
x0_i = x0[i]
h = (1.0 * stepNom[i]) * delta
# evaluate at each step, centered around x0_i
# difference to give a second order estimate
fdel = zeros((n, nsteps))
xp = x0.copy()
xm = x0.copy()
for j in range(nsteps):
xp[i] = x0_i + h[j]
xm[i] = x0_i - h[j]
fdif = fun(xp) - fun(xm)
fdel[:, j] = fdif.ravel()
derest = fdel * 0.5 / h[newaxis,:]
for j in range(n):
der_romb, errest, h1 = self._romb_extrap(derest[j,:], h)
der_romb, errest, h1 = self._trim_estimates(der_romb, errest, h)
ind = errest.argmin()
err[j, i] = errest[ind]
finaldelta[j, i] = h1[ind]
jac[j, i] = der_romb[ind]
self.finaldelta = finaldelta
self.error_estimate = err
return jac
class Gradient(_PartialDerivative):
_grad_txt = _Derivative.__doc__.partition('\n')[2].replace(
'Integer from 1 to 4 defining derivative order. (Default 1)',
'Derivative order is always 1')
__doc__ = ( #@ReservedAssignment
'''Estimate gradient of fun at x0, with error estimate
''' + _grad_txt + '''
Assumptions
-----------
fun : SCALAR analytical function to differentiate.
fun must be a function of the vector or array x0,
but it needs not to be vectorized.
x0 : vector location at which to differentiate fun
If x0 is an N x M array, then fun is assumed to be
a function of N*M variables.
Examples
--------
>>> import numpy as np
>>> import numdifftools as nd
>>> fun = lambda x: np.sum(x**2)
>>> dfun = nd.Gradient(fun)
>>> dfun([1,2,3])
array([ 2., 4., 6.])
# At [x,y] = [1,1], compute the numerical gradient
# of the function sin(x-y) + y*exp(x)
>>> sin = np.sin; exp = np.exp
>>> z = lambda xy: sin(xy[0]-xy[1]) + xy[1]*exp(xy[0])
>>> dz = nd.Gradient(z)
>>> grad2 = dz([1, 1])
>>> grad2
array([ 3.71828183, 1.71828183])
# At the global minimizer (1,1) of the Rosenbrock function,
# compute the gradient. It should be essentially zero.
>>> rosen = lambda x : (1-x[0])**2 + 105.*(x[1]-x[0]**2)**2
>>> rd = nd.Gradient(rosen)
>>> grad3 = rd([1,1])
>>> grad3
array([ 0., 0.])
>>> np.abs(grad3)<=rd.error_estimate
array([ True, True], dtype=bool)
See also
--------
Derivative, Hessdiag, Hessian, Jacobian
''')
def __call__(self, x00):
return self.gradient(x00)
def gradient(self, x00):
''' Gradient vector of an analytical function of n variables
CALL: [grad,err,finaldelta] = fun.gradient(x0)
grad = first partial derivatives of fun evaluated at x0. Size 1 x N
err = error estimates corresponding to each value in grad. Size 1 x N
finaldelta = vector of final step sizes chosen for each partial derivative.
fun = analytical function to differentiate. fun must
be a function of the vector or array x0.
x0 = vector location at which to differentiate fun
If x0 is an nxm array, then fun is assumed to be
a function of N = n*m variables.
GRADEST estimate first partial derivatives of fun evaluated at x0.
GRADEST uses derivest to provide both derivative estimates
and error estimates. fun needs not be vectorized.
Examples
#[grad,err] = gradest(@(x) sum(x.^2),[1 2 3]) # grad = [ 2,4, 6]
'''
self.n = 1
self.vectorized = False
self._initialize()
return self._partial_der(x00)
class Hessdiag(_PartialDerivative):
_hessdiag_txt = _Derivative.__doc__.partition('\n')[2].replace(
'Integer from 1 to 4 defining derivative order. (Default 1)',
'Derivative order is always 2')
__doc__ = ( #@ReservedAssignment
'''Estimate diagonal elements of Hessian of fun at x0,
with error estimate
''' + _hessdiag_txt + '''
HESSDIAG return a vector of second order partial derivatives of fun.
These are the diagonal elements of the Hessian matrix, evaluated
at x0. When all that you want are the diagonal elements of the hessian
matrix, it will be more efficient to call HESSDIAG than HESSIAN.
HESSDIAG uses DERIVATIVE to provide both second derivative estimates
and error estimates.
Assumptions
------------
fun : SCALAR analytical function to differentiate.
fun must be a function of the vector or array x0,
but it needs not to be vectorized.
x0 : vector location at which to differentiate fun
If x0 is an N x M array, then fun is assumed to be
a function of N*M variables.
Examples
--------
>>> import numpy as np
>>> import numdifftools as nd
>>> fun = lambda x : x[0] + x[1]**2 + x[2]**3
>>> ddfun = lambda x : np.asarray((0, 2, 6*x[2]))
>>> Hfun = nd.Hessdiag(fun)
>>> hd = Hfun([1,2,3]) # HD = [ 0,2,18]
>>> hd
array([ 0., 2., 18.])
>>> np.abs(ddfun([1,2,3])-hd) <= Hfun.error_estimate
array([ True, True, True], dtype=bool)
See also
--------
Gradient, Derivative, Hessian, Jacobian
''')
def __call__(self, x00):
return self.hessdiag(x00)
def hessdiag(self, x00):
''' Diagonal elements of Hessian matrix
See also derivative, gradient, hessian, jacobian
'''
self.n = 2
self.vectorized = False
self._initialize()
return self._partial_der(x00)
class Hessian(Hessdiag):
_hessian_txt = _Derivative.__doc__.partition('\n')[2].replace(
'Integer from 1 to 4 defining derivative order. (Default 1)',
'Derivative order is always 2')
__doc__ = ( #@ReservedAssignment
''' Estimate Hessian matrix, with error estimate
''' + _hessian_txt + '''
HESSIAN estimate the matrix of 2nd order partial derivatives of a real
valued function FUN evaluated at X0. HESSIAN is NOT a tool for frequent
use on an expensive to evaluate objective function, especially in a large
number of dimensions. Its computation will use roughly O(6*n^2) function
evaluations for n parameters.
Assumptions
-----------
fun : SCALAR analytical function
to differentiate. fun must be a function of the vector or array x0,
but it needs not to be vectorized.
x0 : vector location
at which to differentiate fun
If x0 is an N x M array, then fun is assumed to be a function
of N*M variables.
Examples
--------
>>> import numpy as np
>>> import numdifftools as nd
# Rosenbrock function, minimized at [1,1]
>>> rosen = lambda x : (1.-x[0])**2 + 105*(x[1]-x[0]**2)**2
>>> Hfun = nd.Hessian(rosen)
>>> h = Hfun([1, 1])
>>> h
array([[ 842., -420.],
[-420., 210.]])
>>> Hfun.error_estimate < 1.e-11
array([[ True, True],
[ True, True]], dtype=bool)
# cos(x-y), at (0,0)
>>> cos = np.cos
>>> fun = lambda xy : cos(xy[0]-xy[1])
>>> Hfun2 = nd.Hessian(fun)
>>> h2 = Hfun2([0, 0])
>>> h2
array([[-1., 1.],
[ 1., -1.]])
>>> np.abs(h2-np.array([[-1, 1],[ 1, -1]])) < Hfun2.error_estimate
array([[ True, True],
[ True, True]], dtype=bool)
>>> Hfun2.romberg_terms = 3
>>> h3 = Hfun2([0,0])
>>> h3
array([[-1., 1.],
[ 1., -1.]])
>>> np.abs(h3-np.array([[-1, 1],[ 1, -1]])) < Hfun2.error_estimate
array([[ True, True],
[ True, True]], dtype=bool)
See also
--------
Gradient,
Derivative,
Hessdiag,
Jacobian
''')
def __call__(self, x00):
return self.hessian(x00)
def hessian(self, x00):
'''Hessian matrix i.e., array of 2nd order partial derivatives
See also derivative, gradient, hessdiag, jacobian
'''
x0 = np.atleast_1d(x00)
nx = len(x0)
self.method = 'central'
hess = self.hessdiag(x0)
err = self.error_estimate
hess, err = np.diag(hess), np.diag(err)
if nx < 2 :
return hess # the hessian matrix is 1x1. all done
# Decide on intelligent step sizes for the mixed partials
stepsize = self.finaldelta
ndel = np.maximum(self._get_min_num_steps(), self.romberg_terms + 2)
dfac = (1.0 * self.step_ratio) ** (-np.arange(ndel))
stepmax = stepsize / dfac[ndel//2]
fun = self.fun
zeros = np.zeros
for i in range(1, nx):
for j in range(i):
dij, step = zeros(ndel), zeros(nx)
step[[i, j]] = stepmax[[i, j]]
for k in range(int(ndel)):
x1 = x0 + step * dfac[k]
x2 = x0 - step * dfac[k]
step[j] = -step[j]
x3 = x0 + step * dfac[k]; step = -step
x4 = x0 + step * dfac[k]
step[i] = -step[i]
dij[k] = fun(x1) + fun(x2) - fun(x3) - fun(x4)
dij = dij / 4 / stepmax[[i, j]].prod() / (dfac ** 2)
hess_romb, errors, _dfac1 = self._romb_extrap(dij, dfac)
ind = errors.argmin()
hess[j, i] = hess[i, j] = hess_romb[ind]
err[j, i] = err[i, j] = errors[ind]
self.error_estimate = err
return hess
def test_docstrings():
import doctest
doctest.testmod()
if __name__ == '__main__':
#test_docstrings()
fun = np.cos
dfun = lambda x: -np.sin(x)
print((2*np.sqrt(1e-16)))
#fun = np.tanh
#dfun = lambda x : 1./np.cosh(x)**2
#fun = np.log
#dfun = lambda x : 1./x
#fun = lambda x : 1./x
#dfun = lambda x : -1./x**2
h = 1e-4
fd = Derivative(fun, method='central', step_max=2,
step_ratio=2, verbose=True, vectorized=True, romberg_terms=3) #2)#, step_nom=9)
# fd = Derivative(fun, method='central', step_ratio=1.62, verbose=True,
# step_fix=2, step_num=None, romberg_terms=2, vectorized=True)
#step_nom=0.0005) #2)#, step_nom=9)
x=1.
t = fd(x)
print(((fun(x+h)-fun(x))/(h), dfun(x), t, dfun(x)-t, fd.error_estimate, fd.error_estimate/t, fd.finaldelta))
| 48,772
|
https://github.com/luoxiao/GPUImage3/blob/master/framework/Source/Operations/HighlightAndShadowTint.metal
|
Github Open Source
|
Open Source
|
BSD-3-Clause
| 2,022
|
GPUImage3
|
luoxiao
|
Metal
|
Code
| 76
| 316
|
#include <metal_stdlib>
#include "OperationShaderTypes.h"
using namespace metal;
typedef struct
{
float shadowTintIntensity;
float highlightTintIntensity;
float3 shadowTintColor;
float3 highlightTintColor;
} HighlightShadowTintUniform;
fragment half4 highlightShadowTintFragment(SingleInputVertexIO fragmentInput [[stage_in]],
texture2d<half> inputTexture [[texture(0)]],
constant HighlightShadowTintUniform& uniform [[ buffer(1) ]])
{
constexpr sampler quadSampler;
half4 color = inputTexture.sample(quadSampler, fragmentInput.textureCoordinate);
half luminance = dot(color.rgb, luminanceWeighting);
half4 shadowResult = mix(color, max(color, half4( mix(half3(uniform.shadowTintColor), color.rgb, luminance), color.a)), half(uniform.shadowTintIntensity));
half4 highlightResult = mix(color, min(shadowResult, half4( mix(shadowResult.rgb, half3(uniform.highlightTintColor), luminance), color.a)), half(uniform.highlightTintIntensity));
return half4(mix(shadowResult.rgb, highlightResult.rgb, luminance), color.a);
}
| 41,048
|
https://github.com/sebdenis/pdsim/blob/master/PDSim/core/core.py
|
Github Open Source
|
Open Source
|
MIT
| 2,022
|
pdsim
|
sebdenis
|
Python
|
Code
| 7,202
| 21,205
|
from __future__ import division, absolute_import, print_function
import math
from math import pi
from timeit import default_timer
import inspect
import six
##-- Package imports --
from PDSim.flow import flow,flow_models
from .containers import STATE_VARS_TM, CVArrays, ControlVolumeCollection,TubeCollection
from PDSim.flow.flow import FlowPathCollection
from . import integrators
from PDSim.misc.datatypes import arraym, empty_arraym
import PDSim.core.callbacks
from PDSim.misc.error_bar import error_ascii_bar
##-- Non-package imports --
import numpy as np
# If scipy is available, use its optimization function, otherwise,
# use our implementation (for packaging purposes)
try:
from scipy.integrate import trapz
except ImportError:
from PDSim.misc.scipylike import trapz
import h5py
# An empty class for storage
class struct(object):
pass
class IntegratorMixin(object):
"""
This class contains the methods that will be merged with one of the system of ODE integrators
and includes the methods that are specific to PDSim
"""
def __init__(self, sim, x_state):
self.sim = sim
self.x_state = x_state
def get_initial_array(self):
# Get the beginning of the cycle configured
# Put a copy of the values into the matrices
xold = self.x_state.copy()
self.sim._put_to_matrices(xold, 0)
return xold
def premature_termination(self):
# Once every 100 steps check if you are supposed to abort
if self.sim._check_cycle_abort(self.Itheta):
return 'abort'
else:
return False
def pre_step_callback(self):
# Call the step callback if provided
if self.sim.callbacks.step_callback is not None:
self.h = self.sim.callbacks.step_callback(self.t0, self.h, self.Itheta)
disable = self.sim.callbacks.step_callback.disable_adaptive
# If we don't want to actually do the step, rather just copy the values
# (for instance at the merging angle for scroll machines), we set
# stepAccepted to True and move on
if disable == 'no_integrate':
self.stepAccepted = True
# Retrieve the array of values based on the values set in step_callback
x = self.sim._get_from_matrices(self.Itheta)
# Updates the state, calculates the volumes, prepares all the things needed for derivatives
# The crank angle must be evaluated after theta_d in order to ensure that the new volumes are used
# The newly calculated values are used
self.sim.core.properties_and_volumes(self.sim.CVs.exists_CV, self.t0+self.h+1e-10, STATE_VARS_TM, x)
self.xold = x.copy()
self.xnew = x.copy()
self.__store_values()
x = self.sim._get_from_matrices(self.Itheta)
if disable != False and x.all_finite():
self.xold = self.sim._get_from_matrices(self.Itheta)
# The integrator only cares whether disable is true or not, convert to true or false
if disable != False:
self.disableAdaptive = True
else:
self.disableAdaptive = False
def __store_values(self):
""" Private method that stores the values in the internal data structure """
self.sim.t[self.Itheta] = self.t0
self.sim._put_to_matrices(self.xold, self.Itheta)
flows = self.sim.Flows.get_deepcopy()
# If the index we want to fill is beyond the length of FlowStorage, we append it,
# otherwise, we replace that entry in the list
if self.Itheta > len(self.sim.FlowStorage)-1:
self.sim.FlowStorage.append(flows)
else:
self.sim.FlowStorage[self.Itheta] = flows
def post_deriv_callback(self):
self.__store_values()
def post_step_callback(self): pass
def derivs(self, t, x):
return self.sim.derivs(t, x)
def post_integration(self):
"""
Run this at the end
"""
# Cache the values
self.sim.derivs(self.t0, self.xold)
self.__store_values()
V, dV = self.sim.CVs.volumes(self.t0)
Nexist = self.sim.CVs.Nexist
if sorted(self.sim.stateVariables) == ['D','T']:
self.sim.CVs.updateStates('T',self.xnew[0:Nexist],'D',self.xnew[Nexist:2*Nexist])
elif sorted(self.sim.stateVariables) == ['M','T']:
self.sim.CVs.updateStates('T',self.xnew[0:Nexist],'D',self.xnew[Nexist:2*Nexist]/V)
else:
raise NotImplementedError
class EulerIntegrator(IntegratorMixin, integrators.AbstractSimpleEulerODEIntegrator):
"""
Mixin class using the functions defined in IntegratorMixin and the generalized simple ODE
"""
def __init__(self, sim, x_state):
IntegratorMixin.__init__(self, sim, x_state)
class HeunIntegrator(IntegratorMixin, integrators.AbstractHeunODEIntegrator):
"""
Mixin class using the functions defined in IntegratorMixin and the generalized Heun ODE integrator
"""
def __init__(self, sim, x_state):
IntegratorMixin.__init__(self, sim, x_state)
class RK45Integrator(IntegratorMixin, integrators.AbstractRK45ODEIntegrator):
"""
Mixin class using the functions defined in IntegratorMixin and the generalized RK45 integrator
"""
def __init__(self, sim, x_state):
IntegratorMixin.__init__(self, sim, x_state)
class PDSimCore(object):
"""
This is the main driver class for the model
This class is not intended to be run on its own. It must be subclassed and extended to provide functions for mass flow, etc.
The basic order of steps that should be followed can be summarized as
#. Instantiate the subclass of PDSimCore
#. Add each of the control volumes
#. Add each of the tubes
#. Add all the flow models between CV and tubes
#. Add valves (if applicable)
#. Connect the callbacks for heat transfer, step, etc.
#. Run the model
"""
def __init__(self,stateVariables=None):
"""
Initialization of the PDSimCore
Parameters
----------
stateVariables : mutable object [list or tuple], optional
list of keys for the state variables to be used. Current options are 'T','D' or 'T','M'. Default state variables are 'T','M'
"""
#Initialize the containers to be empty
#: The Valves container class
self.Valves = []
#: The :class:`ControlVolumeCollection <PDSim.core.containers.ControlVolumeCollection>` instance
#: that contains all the control volumes in the machine
self.CVs = ControlVolumeCollection()
#: The :class:`FlowPathCollection <PDSim.flow.flow.FlowPathCollection>`
#: instance
self.Flows = FlowPathCollection()
#: A :class:`list` that contains copies of the
#: :class:`FlowPathCollection <PDSim.flow.flow.FlowPathCollection>`
#: at each crank angle
self.FlowStorage = []
self.Tubes = TubeCollection()
self.Tlumps = np.zeros((1,1))
self.steps = []
self.__hasValves__ = False
# A storage of the initial state vector
self.xstate_init = None
# A storage of the initial valves vector
if isinstance(stateVariables,(list,tuple)):
self.stateVariables=list(stateVariables)
else:
self.stateVariables=['T','M']
self._want_abort = False
# Build a structure to hold all the callbacks
self.callbacks = PDSim.core.callbacks.CallbackContainer()
# Build a dummy class to hold information from the solvers
class dummy: pass
self.solvers = dummy()
self.solvers.lump_eb_history = []
self.solvers.hdisc_history = []
self.solvers.initial_states_history = []
self.verbosity = 0
self.summary = dummy()
def _check(self):
"""
Do some checking before we start the run.
Here we check:
* Inlet state viscosity and conductivity must be greater than zero
"""
if self.inlet_state.get_visc() < 0:
raise ValueError('Your inlet state viscosity is less than zero. Invalid fluid: ' +self.inlet_state.Fluid)
if self.inlet_state.get_cond() < 0:
raise ValueError('Your inlet state conductivity is less than zero. Invalid fluid: '+self.inlet_state.Fluid)
def _get_from_matrices(self,i):
"""
Get values back from the matrices and reconstruct the state variable list
"""
if self.__hasLiquid__==True:
raise NotImplementedError
else:
ValList = []
exists_indices = np.array(self.CVs.exists_indices)
for s in self.stateVariables:
if s=='T':
ValList += self.T[exists_indices,i].tolist()
elif s=='D':
ValList += self.rho[exists_indices,i].tolist()
elif s=='M':
ValList += self.m[exists_indices,i].tolist()
else:
raise KeyError
if self.__hasValves__:
# Also store the valve values
ValList += self.xValves[:,i].tolist()
return arraym(ValList)
def _statevars_to_dict(self,x):
d={}
for iS,s in enumerate(self.stateVariables):
x_=(x[iS*self.CVs.Nexist:self.CVs.Nexist*(iS+1)])
if s=='T':
d['T']=x_
elif s=='D':
d['D']=x_
elif s=='M':
d['M']=x_
return d
def _put_to_matrices(self,x,i):
"""
Take a state variable list and put back in numpy matrices
"""
exists_indices=self.CVs.exists_indices
Nexist = self.CVs.Nexist
Ns = len(self.stateVariables)
assert(len(x) == len(self.Valves)*2+Ns*Nexist)
if self.__hasLiquid__==True:
raise NotImplementedError
# self.T[:,i]=x[0:self.NCV]
# self.m[:,i]=x[self.NCV:2*self.NCV]
else: # self.__hasLiquid__==False
for iS, s in enumerate(self.stateVariables):
if s=='T':
self.T[exists_indices, i] = x[iS*self.CVs.Nexist:self.CVs.Nexist*(iS+1)]
elif s=='D':
self.rho[exists_indices, i] = x[iS*self.CVs.Nexist:self.CVs.Nexist*(iS+1)]
elif s=='M':
self.m[exists_indices, i] = x[iS*self.CVs.Nexist:self.CVs.Nexist*(iS+1)]
# Left over terms are for the valves
if self.__hasValves__:
self.xValves[0:len(self.Valves)*2, i] = arraym(x[Ns*Nexist:len(x)])
# In the first iteration, self.core has not been filled, so do not
# overwrite with the values in self.core.m and self.core.rho
if self.core.m[0] > 0.0 :
self.m[exists_indices, i] = self.core.m
if self.core.rho[0] > 0.0 :
self.rho[exists_indices, i] = self.core.rho
self.V[exists_indices, i] = self.core.V
self.dV[exists_indices, i] = self.core.dV
self.p[exists_indices, i] = self.core.p
self.h[exists_indices, i] = self.core.h
self.Q[exists_indices,i] = self.core.Q
def _postprocess_flows(self):
"""
In this private method, the flows from each of the flow nodes are summed for
each step of the revolution, and then averaged flow rates are calculated.
"""
def sum_flows(key,Flows):
"""
Sum all the terms for a given flow key.
Flows "into" the node are positive, flows out of the
node are negative
Use the code in the Cython module
"""
return flow.sumterms_given_CV(key, Flows)
def collect_keys(Tubes,Flows):
"""
Get all the keys for a given collection of flow elements
"""
keys=[]
for Tube in Tubes:
if Tube.key1 not in keys:
keys.append(Tube.key1)
if Tube.key2 not in keys:
keys.append(Tube.key2)
for Flow in Flows:
if Flow.key1 not in keys:
keys.append(Flow.key1)
if Flow.key2 not in keys:
keys.append(Flow.key2)
return keys
# Get all the nodes that can exist for tubes and CVs
keys=collect_keys(self.Tubes,self.Flows)
# Get the instantaneous net flow through each node
# and the averaged mass flow rate through each node
self.FlowsProcessed=struct()
self.FlowsProcessed.summed_mdot={}
self.FlowsProcessed.summed_mdoth={}
self.FlowsProcessed.mean_mdot={}
self.FlowsProcessed.integrated_mdoth={}
self.FlowsProcessed.integrated_mdot={}
self.FlowsProcessed.t=self.t[0:self.Ntheta]
for key in keys:
# Empty container numpy arrays
self.FlowsProcessed.summed_mdot[key]=np.zeros((self.Ntheta,))
self.FlowsProcessed.summed_mdoth[key]=np.zeros((self.Ntheta,))
assert self.Ntheta == len(self.FlowStorage)
for i in range(self.Ntheta):
mdot,mdoth=sum_flows(key,self.FlowStorage[i])
self.FlowsProcessed.summed_mdot[key][i]=mdot
self.FlowsProcessed.summed_mdoth[key][i]=mdoth
# All the calculations here should be done in the time domain,
# rather than crank angle. So convert angle to time by dividing
# by omega, the rotational speed in rad/s.
trange = self.t[self.Ntheta-1]-self.t[0]
# integrated_mdoth has units of kJ/rev * f [Hz] --> kJ/s or kW
self.FlowsProcessed.integrated_mdoth[key]=trapz(self.FlowsProcessed.summed_mdoth[key],
self.t[0:self.Ntheta]/self.omega)*self.omega/trange
# integrated_mdot has units of kg/rev * f [Hz] --> kg/s
self.FlowsProcessed.integrated_mdot[key]=trapz(self.FlowsProcessed.summed_mdot[key],
self.t[0:self.Ntheta]/self.omega)*self.omega/trange
self.FlowsProcessed.mean_mdot[key]=np.mean(self.FlowsProcessed.integrated_mdot[key])
# Special-case the tubes. Only one of the nodes can have flow.
# The other one is invariant because it is quasi-steady.
for Tube in self.Tubes:
mdot1 = self.FlowsProcessed.mean_mdot[Tube.key1]
mdot2 = self.FlowsProcessed.mean_mdot[Tube.key2]
mdot_i1 = self.FlowsProcessed.integrated_mdot[Tube.key1]
mdot_i2 = self.FlowsProcessed.integrated_mdot[Tube.key2]
mdoth_i1 = self.FlowsProcessed.integrated_mdoth[Tube.key1]
mdoth_i2 = self.FlowsProcessed.integrated_mdoth[Tube.key2]
#Swap the sign so the sum of the mass flow rates is zero
self.FlowsProcessed.mean_mdot[Tube.key1] -= mdot2
self.FlowsProcessed.mean_mdot[Tube.key2] -= mdot1
self.FlowsProcessed.integrated_mdot[Tube.key1] -= mdot_i2
self.FlowsProcessed.integrated_mdot[Tube.key2] -= mdot_i1
self.FlowsProcessed.integrated_mdoth[Tube.key1] -= mdoth_i2
self.FlowsProcessed.integrated_mdoth[Tube.key2] -= mdoth_i1
#For each tube, update the flow going through it
#Tube.mdot is always a positive value
Tube.mdot = max(abs(mdot1), abs(mdot2))
self.mdot = self.FlowsProcessed.mean_mdot[self.key_inlet]
self.FlowsProcessed.collected_data = []
for i, Flow in enumerate(self.Flows):
mdot = np.array([Flows[i].mdot for Flows in self.FlowStorage])
edot = np.array([Flows[i].edot for Flows in self.FlowStorage])
data = dict(key1 = Flow.key1,
key2 = Flow.key2,
fcn = Flow.MdotFcn_str,
mdot = mdot,
edot = edot,
mdot_average = np.trapz(mdot, self.t[0:self.Ntheta])/(self.t[self.Ntheta-1]-self.t[0]),
Edot_average = np.trapz(edot, self.t[0:self.Ntheta])/(self.t[self.Ntheta-1]-self.t[0])
)
self.FlowsProcessed.collected_data.append(data)
def _postprocess_HT(self):
"""
Postprocess the heat transfer terms
Here we
calculate the mean heat transfer rate over the course of the cycle
"""
self.HTProcessed=struct()
r = list(range(self.Ntheta))
#Remove all the NAN placeholders and replace them with zero values
self.Q[np.isnan(self.Q)] = 0.0
#Sum at each step of the revolution
self.HTProcessed.summed_Q = np.sum(self.Q, axis = 0) #kW
#Get the mean heat transfer rate
self.HTProcessed.mean_Q = trapz(self.HTProcessed.summed_Q[r], self.t[r])/(self.t[self.Ntheta-1]-self.t[0])
def guess_outlet_temp(self, inlet_state, p_outlet, eta_a=0.7):
"""
Function to guess outlet temperature
Using a guess value for the adiabatic efficiency, calculate the guessed
outlet temperature. In compressor mode, the adiabatic efficiency is defined by
.. math::
\eta_a = \\frac{h_{2s}-h_1}{h_2-h_1}
and in expander mode it is defined by
.. math::
\eta_a = \\frac{h_2-h_1}{h_{2s}-h_1}
This function can also be overloaded by the subclass in order to
implement a different guess method
"""
h1 = inlet_state.h
out_state = inlet_state.copy()
out_state.update(dict(S = inlet_state.s, P = p_outlet))
h2s = out_state.h
if p_outlet > inlet_state.p:
# Compressor Mode
h2 = h1 + (h2s-h1)/eta_a
else:
# Expander Mode
h2 = h1 + (h2s-h1)*eta_a
out_state.update(dict(H = h2, P = p_outlet))
return out_state.T
def reset_initial_state(self):
"""
Reset the initial state of the core class, typically after doing a
preconditioning run
"""
for k,CV in zip(self.CVs.keys,self.CVs.CVs):
if k in self.exists_CV_init:
CV.exists = True
else:
CV.exists = False
#Update the existence of each of the CV
self.update_existence()
#Only the State variables, not the valves
self.x_state = self.xstate_init
#Make a copy
x = self.xstate_init.copy()
#Add the values from the valves
if self.__hasValves__:
x.extend(empty_arraym(2*len(self.Valves)))
self._put_to_matrices(x, 0)
#Reset the temporary variables
self.xstate_init = None
self.exists_CV_init = None
def update_existence(self):
"""
Update existence flags for Tubes and control volumes
This function is required to be called when the existence of any control
volume or tube changes in order to ensure that internal flags are set
properly
"""
# Update the existence flags in all the control volumes
self.CVs.rebuild_exists()
# Update the array of enthalpies in the tubes
self.Tubes.update_existence(self.CVs.Nexist)
# Update the existence of each of the flows
self.Flows.update_existence(self)
# Update the sizes of the internal arrays in self.core
self.core.update_size(self.CVs.Nexist)
def add_flow(self,FlowPath):
"""
Add a flow path to the model
Parameters
----------
FlowPath : :class:`FlowPath <PDSim.flow.flow.FlowPath>` instance
An initialized flow path
"""
#Add FlowPath instance to the list of flow paths
self.Flows.append(FlowPath)
def add_CV(self,CV):
"""
Add a control volume to the model
Parameters
----------
CV : :class:`ControlVolume <PDSim.core.containers.ControlVolume>` instance
An initialized control volume
"""
if CV.key in self.CVs.keys:
raise KeyError('Sorry but the key for your Control Volume ['+CV.key+'] is already in use')
#Add the CV to the collection
self.CVs.add(CV)
self.CVs.rebuild_exists()
def add_tube(self,Tube):
"""
Add a tube to the model.
Parameters
----------
Tube : :class:`Tube <PDSim.core.containers.Tube>` instance
An initialized tube.
"""
#Add it to the list
self.Tubes.append(Tube)
self.Tubes.update()
def add_valve(self,Valve):
"""
Add a valve to the model.
Parameters
----------
Valve : :class:`ValveModel <PDSim.flow.flow_models.ValveModel>` instance
An initialized valve.
"""
#Add it to the list
self.Valves.append(Valve)
self.__hasValves__=True
def pre_run(self, N = 40000):
"""
This function gets called before the run begins. It builds large matrices
to store values, and does other initialization.
"""
# Build the full numpy arrays for temperature, volume, etc.
self.t=np.zeros((N,))
self.T=np.zeros((self.CVs.N,N))
self.T.fill(np.nan)
self.p=self.T.copy()
self.h = self.T.copy()
self.m = self.T.copy()
self.V = self.T.copy()
self.dV = self.T.copy()
self.rho = self.T.copy()
self.Q = self.T.copy()
self.xValves = np.zeros((2*len(self.Valves),N))
# Initialize the core class that contains the arrays and the derivs
self.core = CVArrays(0)
# Update the existence of all the control volumes
self.update_existence()
# Set a flag about liquid flooding
self.__hasLiquid__ = False
def pre_cycle(self, x0 = None):
"""
This runs before the cycle is run but after pre_run has been called
Parameters
----------
x0 : :class:`arraym <PDSim.misc.datatypes.arraym>` instance
"""
self.t.fill(np.nan)
self.T.fill(np.nan)
self.p.fill(np.nan)
self.m.fill(np.nan)
self.V.fill(np.nan)
self.dV.fill(np.nan)
self.rho.fill(np.nan)
self.Q.fill(np.nan)
self.FlowStorage=[]
#Get the volumes at theta=0
#Note: needs to occur in this function because V needed to calculate mass a few lines below
VdV=[CV.V_dV(0.0,**CV.V_dV_kwargs) for CV in self.CVs.exists_CV]
V,dV = zip(*VdV)
self.t[0]=0
# If x0 is provided, use its values to initialize the chamber states
if x0 is None:
# self.CVs.exists_indices is a list of indices of the CV with the same order of entries
# as the entries in self.CVs.T
self.T[self.CVs.exists_indices, 0] = self.CVs.T
self.p[self.CVs.exists_indices, 0] = self.CVs.p
self.rho[self.CVs.exists_indices, 0] = self.CVs.rho
self.m[self.CVs.exists_indices, 0] = self.CVs.rho*arraym(V)
else:
#x0 is provided, but need to pad it out to include valve values
x0_ = x0.copy()
# If x0 is longer than the product of the number of state variables
# and CV in existence, the valve data is already included and must not be
# added to the array of independent variables
if self.__hasValves__ and len(x0) == self.CVs.Nexist*len(self.stateVariables):
#Load up the rest of the array with zeros since the valves start closed and at rest
x0_.extend(empty_arraym(len(self.Valves)*2))
self._put_to_matrices(x0_, 0)
# Assume all the valves to be fully closed and stationary at the beginning of cycle
self.xValves[:,0]=0
self.Tubes_hdict={}
for Tube in self.Tubes:
self.Tubes_hdict[Tube.key1]=Tube.State1.get_h()
self.Tubes_hdict[Tube.key2]=Tube.State2.get_h()
def calc_boundary_work(self):
"""
This method calculates the boundary work rate using a trapezoidal
integration of
.. math::
\\dot W_{pv} = -\int p\\frac{dV}{d\\theta}\\frac{\\omega}{2\\pi} d\\theta
for all the control volumes and sets the parameter ``self.Wdot_pv`` with
the result.
The units of the boundary work are kW.
"""
def Wdot_one_CV(CVindex):
""" calculate the p-v work for one CV """
x0_raw = self.t[0:self.Ntheta]
y0_raw = self.p[CVindex, 0:self.Ntheta]*self.dV[CVindex, 0:self.Ntheta]
# Convert into chunks that are delimited by nan, if any
isnotnan_indices = np.flatnonzero(~np.isnan(y0_raw))
breaks = np.flatnonzero(np.diff(isnotnan_indices) > 1)
if len(breaks) != 0:
chunks = np.split(isnotnan_indices, np.array(breaks)+1)
else:
chunks = [isnotnan_indices]
return -sum([trapz(y0_raw[ii], x0_raw[ii]) for ii in chunks])*self.omega/(2*pi)
self.Wdot_pv = 0.0
for CVindex in range(self.p.shape[0]):
self.Wdot_pv+=Wdot_one_CV(CVindex)
def post_cycle(self):
"""
This stuff all happens at the end of the cycle. It is a private method
not meant to be called externally
The following things are done:
#. The boundary work is calculated
#. The flows are post-processed
#. The heat transfer is post-processed
#. The mass flow rate is calculated
#. The volumetric efficiency is calculated
#. The adiabatic efficiency is calculated
#. The isentropic power is calculated
#. The power input is calculated
"""
self.calc_boundary_work()
self._postprocess_flows()
self._postprocess_HT()
# Calculate the lumped mass energy balance
if self.callbacks.lumps_energy_balance_callback is not None:
self.lumps_resid = self.callbacks.lumps_energy_balance_callback()
# Convert to an arraym if needed
if not isinstance(self.lumps_resid, arraym):
self.lumps_resid = arraym(self.lumps_resid)
else:
raise ValueError('lumps_energy_balance_callback cannot be None')
if not hasattr(self,'Qamb'):
self.Qamb = 0
# The total mass flow rate
self.mdot = self.FlowsProcessed.mean_mdot[self.key_inlet]
for key, State in six.iteritems(self.Tubes.Nodes):
if key == self.key_inlet:
inletState = State
if key == self.key_outlet:
outletState = State
try:
Vdisp = self.Vdisp
except:
Vdisp = self.Vdisp()
self.eta_v = self.mdot / (self.omega/(2*pi)*Vdisp*inletState.rho)
h1 = inletState.h
h2 = outletState.h
s1 = inletState.s
# Can't use intermediate temperature because the state might be two-phase
# for some conditions and you are better off just calculating the enthalpy
# directly
temp = outletState.copy()
temp.update(dict(P=outletState.p, S=s1))
h2s = temp.h
if outletState.p > inletState.p:
# Compressor Mode
self.eta_a = (h2s-h1)/(h2-h1)
self.Wdot_i = self.mdot*(h2s-h1)
else:
# Expander Mode
self.eta_a = (h1-h2)/(h1-h2s)
self.Wdot_i = self.mdot*(h1-h2s)
# self.Qamb is positive if heat is being added to the lumped mass
self.Wdot = self.mdot*(h2-h1)-self.Qamb
def _check_cycle_abort(self, index, I = 100):
"""
This function will check whether an abort has been requested every
``I`` steps of the solver throughout the rotation
Meant for calling by cycle_RK45, cycle_SimpleEuler, cycle_Heun, etc.
Primarily this is useful for use with the GUI, where the GUI can pass
an abort command to the model
Parameters
----------
index : int
The index of the step
I : int, optional
Check abort at this interval
"""
# % is the symbol for modulus in python
if index % I == 0 and self.Abort():
self._want_abort = True
return True
def check_abort(self):
"""
A callback for use with the graphical user interface to force solver to quit
It will check the Scroll.pipe_abort pipe for a ``True`` value, and if it
finds one, it will set the Scroll._want_abort value to ``True`` which
will be read by the main execution thread
Once ``self._want_abort`` is ``True``, it will stay latched ``True`` until the
run is terminated
"""
# If you received an abort request, set a flag in the simulation
if self.pipe_abort.poll() and self.pipe_abort.recv():
print('received an abort request')
self._want_abort = True
# If the run has timed out, quit
if default_timer() - self.start_time > self.timeout:
print('run timed out')
self._want_abort = True
return self._want_abort
def precond_solve(self,**kwargs):
"""
This function is deprecated and will be removed in a future version
"""
import warnings
msg = 'precond_solve is deprecated and will be removed in a future version. Please use solve instead'
warnings.warn(msg, DeprecationWarning)
self.solve(**kwargs)
def connect_callbacks(self,
step_callback=None,
heat_transfer_callback=None,
lumps_energy_balance_callback=None,
endcycle_callback=None
):
"""
Connect up the callbacks for the simulation
The callbacks must either be unbound methods or methods of a class derived from PDSimCore
No keyword arguments are supported to be passed to the callbacks. The
callback is probably a bound method of a PDSimCore instance, in which
case you have access to all the data in the class anyway
Parameters
----------
step_callback : function, or :class:`StepCallback <PDSim.core.callbacks.StepCallback>` subclass
If a function is provided, it must have the call signature::
disable_adaptive,h = step_callback(double t, double h, int i)
where ``h`` is the step size that the adaptive solver wants to use, ``t`` is the current value of the independent variable, and ``i`` is the index in the container variables. The return value ``disableAdaptive`` is a boolean value that describes whether the adaptive method should be turned off for this step ( ``False`` : use the adaptive method), and ``h`` is the step size you want to use. If you don't want to disable the adaptive method and use the given step size, just::
return False,h
in your code.
heat_transfer_callback : function, or :class:`HeatTransferCallback <PDSim.core.callbacks.HeatTransferCallback>` subclass
If a function is provided, the heat_transfer_callback function must have the call signature::
Q = heat_transfer_callback(double t)
It should return an :class:`arraym <PDSim.misc.datatypes.arraym>` instance
with the same length as the number of CV in existence.
The entry in the :class:`arraym <PDSim.misc.datatypes.arraym>` is
positive if the heat transfer is TO the fluid in the CV in order
to maintain the sign convention that energy (or mass) input is
positive.
lumps_energy_balance_callback : function, or :class:`LumpsEnergyBalanceCallback <PDSim.core.callbacks.LumpsEnergyBalanceCallback>` subclass
If a function is provided, the lumps_energy_balance_callback
function must have the call signature::
r = lumps_energy_balance_callback()
It should return an :class:`arraym <PDSim.misc.datatypes.arraym>`
instance with the same length as the number of lumps. The entry in
``r`` is the value of the energy balance. It will be driven to zero
by the solver
"""
if step_callback is None:
#No callback is provided, don't do anything
pass
elif isinstance(step_callback, PDSim.core.callbacks.StepCallback):
#If the cythonized step callback is provided, hold onto it
self.callbacks.step_callback = step_callback
#Otherwise, wrap the desired callback if it has the right signature
else:
#Check the functional call
callargs = inspect.getcallargs(step_callback, 0.0, 1e-10, 0)
# Either a non-bound method is provided, or bound method is provided, in which case you get self,t,h,i as the values
# t is a subclass of float, h is a subclass of float, is a subclass of int, and self is subclass of PDSimCore
if not all([isinstance(arg,(float,int,PDSimCore)) for arg in callargs.values()]):
sig_ok = False
else:
if len(callargs) in [3,4]:
sig_ok = True
else:
sig_ok = False
if step_callback is not None and sig_ok:
self.callbacks.step_callback = PDSim.core.callbacks.WrappedStepCallback(self, step_callback)
else:
raise ValueError("step_callback is not possible to be wrapped - neither a subclass of StepCallback nor acceptable function signature")
if heat_transfer_callback is None:
#No callback is provided, don't do anything
pass
elif isinstance(heat_transfer_callback, PDSim.core.callbacks.HeatTransferCallback):
#If the cythonized heat transfer callback is provided, hold a pointer to it
self.callbacks.heat_transfer_callback = heat_transfer_callback
else:
callargs = inspect.getcallargs(heat_transfer_callback, 0.0)
# Either a non-bound method is provided, or bound method is provided, in which case you get self,t as the values
# t is a subclass of float, and self is subclass of PDSimCore
if not all([isinstance(arg,(float,int,PDSimCore)) for arg in callargs.values()]):
sig_ok = False
else:
if len(callargs) in [1,2]:
sig_ok = True
else:
sig_ok = False
#Otherwise, wrap the desired callback if it has the right signature
if heat_transfer_callback is not None and sig_ok:
self.callbacks.heat_transfer_callback = PDSim.core.callbacks.WrappedHeatTransferCallback(self, heat_transfer_callback)
else:
raise ValueError("heat_transfer_callback is not possible to be wrapped - neither a subclass of HeatTransferCallback nor an acceptable function")
if lumps_energy_balance_callback is None:
#No callback is provided, don't do anything
pass
elif isinstance(lumps_energy_balance_callback, PDSim.core.callbacks.LumpsEnergyBalanceCallback):
#If the cythonized lump energy balance callback is provided, hold onto it
self.callbacks.lumps_energy_balance_callback = lumps_energy_balance_callback
#Otherwise, wrap the desired callback if it has the right signature
else:
callargs = inspect.getcallargs(lumps_energy_balance_callback)
# Either a non-bound method is provided, or bound method is provided, in which case you get self,t as the values
# t is a subclass of float, and self is subclass of PDSimCore
sig_ok = len(callargs) == 0 or (len(callargs) == 1 and isinstance(list(callargs.values())[0],PDSimCore))
if lumps_energy_balance_callback is not None and sig_ok: #Do functional introspection here where the ``True`` is
self.callbacks.lumps_energy_balance_callback = PDSim.core.callbacks.WrappedLumpsEnergyBalanceCallback(self, lumps_energy_balance_callback)
else:
raise ValueError("lump_energy_balance_callback is not possible to be wrapped - neither a subclass of LumpsEnergyBalanceCallback nor an acceptable function")
self.callbacks.endcycle_callback = endcycle_callback
def one_cycle(self,
X,
cycle_integrator = 'RK45',
cycle_integrator_options = None):
"""
Only run one cycle
Parameters
----------
cycle_integrator : str
One of 'RK45','Euler','Heun'
cycle_integrator_options : dict
options to be passed to the solver function (RK45, Euler, etc.)
"""
# Make cycle_integrator_options an empty dictionary if not provided
if cycle_integrator_options is None:
cycle_integrator_options = {}
tmin = 0.0
tmax = 2*math.pi
else:
tmin = cycle_integrator_options['tmin']
tmax = cycle_integrator_options['tmax']
X = arraym(X)
# (1). First, run all the tubes
for tube in self.Tubes:
tube.TubeFcn(tube)
# Call update_existence to save the enthalpies for the tubes
self.update_existence()
try:
t1 = default_timer()
# Run the pre-cycle code
self.pre_cycle()
if cycle_integrator == 'Euler':
# Default to 7000 steps if not provided
N = getattr(self,'EulerN', 7000)
integrator = EulerIntegrator(self, X)
aborted = integrator.do_integration(N, tmin, tmax)
elif cycle_integrator == 'Heun':
# Default to 7000 steps if not provided
N = getattr(self,'HeunN', 7000)
integrator = HeunIntegrator(self, X)
aborted = integrator.do_integration(N, tmin, tmax)
elif cycle_integrator == 'RK45':
# Default to tolerance of 1e-8 if not provided
eps_allowed = getattr(self,'RK45_eps', 1e-8)
integrator = RK45Integrator(self, X)
aborted = integrator.do_integration(tmin, tmax, eps_allowed=eps_allowed)
else:
raise AttributeError('solver_method should be one of RK45, Euler, or Heun')
if aborted == False:
integrator.post_integration()
self.Itheta = integrator.Itheta
self.Ntheta = self.Itheta + 1
# Make sure we got the right number of things
assert self.Ntheta == len(self.FlowStorage)
self.post_cycle()
except ValueError:
# debug_plots(self)
raise
if aborted is None:
aborted = False
# Quit if you have aborted in one of the cycle solvers
if aborted == 'abort':
return None
t2 = default_timer()
print('Elapsed time for cycle is {0:g} s'.format(t2-t1))
mdot_out = self.FlowsProcessed.mean_mdot[self.key_outlet]
mdot_in = self.FlowsProcessed.mean_mdot[self.key_inlet]
if hasattr(self, 'additional_inlet_keys'):
for key in self.additional_inlet_keys:
mdot_in += self.FlowsProcessed.mean_mdot[key]
if hasattr(self, 'additional_outlet_keys'):
for key in self.additional_outlet_keys:
mdot_out += self.FlowsProcessed.mean_mdot[key]
# We need to find the key at the inlet to the outlet tube.
Tube = self.Tubes[self.key_outlet]
if Tube.key1 == self.key_outlet:
key_outtube_inlet = Tube.key2
elif Tube.key2 == self.key_outlet:
key_outtube_inlet = Tube.key1
# This is the so-called hd' state at the outlet of the pump set
self.h_outlet_pump_set = (self.FlowsProcessed.integrated_mdoth[key_outtube_inlet]
/self.FlowsProcessed.integrated_mdot[key_outtube_inlet])
# It should be equal to the enthalpy of the fluid at the inlet
# to the outlet tube at the current Td value
h_outlet_Tube = self.Tubes.Nodes[key_outtube_inlet].h
# Residual is the difference of these two terms
# We put it in kW by multiplying by flow rate
self.resid_Td = 0.1*(h_outlet_Tube - self.h_outlet_pump_set)
def OBJECTIVE_CYCLE(self, Td_Tlumps0, X, epsilon_cycle = 0.003, epsilon_energy_balance = 0.003, cycle_integrator = 'RK45', OneCycle = False, cycle_integrator_options = None, plot_every_cycle = False):
"""
The Objective function for the energy balance solver
Parameters
----------
Td_Tlumps0 : list
Discharge temperature and lump temperatures
X : :class:`arraym <PDSim.misc.datatypes.arraym>` instance
Contains the state variables for all the control volumes in existence, as well as any other integration variables
epsilon : float
Convergence criterion applied to all of the solvers (DEPRECATED!)
epsilon_cycle : float
Cycle-cycle convergence criterion
epsilon_energy_balance : float
Energy balance convergence criterion
cycle_integrator : string, one of 'RK45','Euler','Heun'
Which solver is to be used to integrate the steps
OneCycle : bool
If ``True``, stop after one cycle
plot_every_cycle : bool
If ``True``, make the debug plots at every cycle
cycle_integrator_options : dict
Options to be passed to cycle integrator
"""
# Consume the first element as the discharge temp
self.Td = float(Td_Tlumps0.pop(0))
# The rest are the lumps in order
self.Tlumps = Td_Tlumps0
# The first time this function is run, save the state variables
if self.xstate_init is None:
self.xstate_init = X
self.exists_CV_init = self.CVs.exists_keys
i = 0
while True:
# Actually run the cycle, runs post_cycle at the end,
# sets the parameter lumps_resid in this class
# Also sets resid_Td
self.one_cycle(X,
cycle_integrator = cycle_integrator,
cycle_integrator_options = cycle_integrator_options)
if self.Abort():
return
errors, X = self.callbacks.endcycle_callback()
error_metric = np.sqrt(np.sum(np.power(errors, 2)))
### -----------------------------------
### The lump temperatures
### -----------------------------------
self.solvers.lump_eb_history.append([self.Tlumps, self.lumps_resid])
if len(self.Tlumps) > 1:
print("Running multi-lump analysis")
if self.OEB_solver == 'MDNR':
# Use Multi Dim. Newton Raphson step for multi-lump temperatures
w = 1.0
dx = 0.5
x = np.array(self.Tlumps,dtype=np.float)
J = np.zeros((len(x),len(x)))
error = 999
# If a float is passed in for dx, convert to a numpy-like list the same shape
# as x
if isinstance(dx,int) or isinstance(dx,float):
dx=dx*np.ones_like(x)
r0 = np.array(self.lumps_resid)*1000
# Build the Jacobian matrix by columns
for jj in range(len(self.Tlumps)):
delta = np.zeros_like(x)
delta[jj] = dx[jj]
self.Tlumps = self.Tlumps + delta
ri = self.callbacks.lumps_energy_balance_callback()
#print('ri:',ri)
ri = np.array(ri)
J[:,jj] = (ri-r0)/delta[jj]
v = np.linalg.solve(J,-r0)
# Calculate new Tlumps
Tnew = x + w*v
self.Tlumps = Tnew
elif self.OEB_solver == 'Broyden':
# Use Broyden Method
raise('Broyden not implemented yet')
else:
# Use Relaxed Secant Method for single lump temperature
print("Running single-lump analysis")
if len(self.solvers.lump_eb_history) == 1:
T, EB = self.solvers.lump_eb_history[-1]
# T and EB are one-element lists, get floats
_T, _EB = T[0], EB[0]
# Use the thermal mass to make the step
# Here is the logic:
# Instantaneous energy balance given by
# dU/dt = m*c*(dT/dt) = sum(Qdot)
# and if dt = one cycle period (seconds/rev) Deltat = 2*pi/omega
# DELTAT = sum(Qdot)*Deltat/(m*c)
thermal_capacitance = 0.49*0.001 # [kJ/K]
Deltat = (2*np.pi)/self.omega # [s]
# Update the lump temperatures
Tnew = np.array([_T + _EB*Deltat/thermal_capacitance])
else:
# Get the values from the history
Tn1, EBn1 = self.solvers.lump_eb_history[-1]
Tn2, EBn2 = self.solvers.lump_eb_history[-2]
# Convert to numpy arrays
Tn1, EBn1, Tn2, EBn2 = [np.array(l) for l in [Tn1, EBn1, Tn2, EBn2]]
# Use the relaxed secant method to find the solution
Tnew = Tn1 - 0.7*EBn1*(Tn1-Tn2)/(EBn1-EBn2)
# Update the lump temperatures
self.Tlumps = Tnew.tolist()
### -----------------------------------
### The discharge enthalpy
### -----------------------------------
# The outlet tube
outlet_tube = self.Tubes[self.key_outlet]
# Get the keys for the elements of the outlet tube
if outlet_tube.key1 == self.key_outlet:
key_outtube_inlet = outlet_tube.key2
key_outtube_outlet = outlet_tube.key1
elif outlet_tube.key2 == self.key_outlet:
key_outtube_inlet = outlet_tube.key1
if error_metric < 0.1*epsilon_cycle and np.max(np.abs(self.lumps_resid)) < epsilon_energy_balance:
# Each time that we get here and we are significantly below the threshold, store the values
# Get the current value for the outlet enthalpy of the machine
h_outlet = self.Tubes[self.key_outlet].State2.get_h()
# Store the values in the list of values
self.solvers.hdisc_history.append([h_outlet,self.resid_Td])
if len(self.solvers.hdisc_history) == 1:
# The first time we get here, perturb the discharge enthalpy
self.Tubes.Nodes[self.key_outlet].update_ph(self.Tubes.Nodes[self.key_outlet].p, h_outlet + 5)
else:
# Get the values from the history
hdn1, EBn1 = self.solvers.hdisc_history[-1]
hdn2, EBn2 = self.solvers.hdisc_history[-2]
# Use the relaxed secant method to find the solution
hdnew = hdn1 - 0.75*EBn1*(hdn1-hdn2)/(EBn1-EBn2)
# Reset the outlet enthalpy of the outlet tube based on our new
# value for it
self.Tubes.Nodes[self.key_outlet].update_ph(self.Tubes.Nodes[self.key_outlet].p, hdnew)
print(self.solvers.hdisc_history)
print('New outlet T:', self.Tubes.Nodes[self.key_outlet].T, 'K')
# Store a copy of the initial temperatures of the chambers
self.solvers.initial_states_history.append(self.T[:,0].copy())
if OneCycle:
print('Quitting due to OneCycle being set to True')
return
if plot_every_cycle:
from PDSim.plot.plots import debug_plots
debug_plots(self)
if self.Abort():
print('Quitting because Abort flag hit')
return
# Reset the flag for the fixed side of the outlet tube
#outlet_tube.fixed = old_fixed
mdot_out = abs(self.FlowsProcessed.mean_mdot[self.key_outlet])
mdot_in = abs(self.FlowsProcessed.mean_mdot[self.key_inlet])
if hasattr(self, 'additional_inlet_keys'):
for key in self.additional_inlet_keys:
print('Additional inlet flow:', key, self.FlowsProcessed.mean_mdot[key]*1000, 'g/s')
mdot_in += self.FlowsProcessed.mean_mdot[key]
if hasattr(self, 'additional_outlet_keys'):
for key in self.additional_outlet_keys:
print('Additional outlet flow:', key, self.FlowsProcessed.mean_mdot[key]*1000, 'g/s')
mdot_out += self.FlowsProcessed.mean_mdot[key]
mdot_error = (mdot_out/mdot_in-1)*100
print('===========')
print('|| # {i:03d} ||'.format(i=i))
print('===========')
print(error_ascii_bar(abs(self.lumps_resid[0]), epsilon_energy_balance), 'energy balance kW ', self.lumps_resid, ' Tlumps: ',self.Tlumps,'K')
print(error_ascii_bar(abs(self.resid_Td), epsilon_energy_balance), 'discharge state', self.resid_Td, 'h_pump_set: ', self.h_outlet_pump_set,'kJ/kg', self.Tubes.Nodes[key_outtube_inlet].h, 'kJ/kg')
print(error_ascii_bar(error_metric, epsilon_cycle), 'cycle-cycle ', error_metric)
print(error_ascii_bar(abs(mdot_error), 1), 'mdot [%]', mdot_error, '|| in:', mdot_in*1000, 'g/s || out:', mdot_out*1000, 'g/s ')
# Check all the stopping conditions
within_tolerance = [
np.max(np.abs(self.lumps_resid)) < epsilon_energy_balance,
abs(self.resid_Td) < epsilon_energy_balance,
np.sqrt(np.sum(np.power(errors, 2))) < epsilon_cycle
]
# Stop if all conditions are met
if all(within_tolerance):
break
i += 1
# If the abort function returns true, quit this loop
if self.Abort():
print('Quitting OBJECTIVE_CYCLE loop in core.solve')
return None # Stop
else:
if len(self.solvers.hdisc_history) == 0:
# Store the values in the list of values
self.solvers.hdisc_history.append([self.Tubes[self.key_outlet].State2.get_h(),self.resid_Td])
def solve(self,
key_inlet = None,
key_outlet = None,
solver_method = 'Euler',
OneCycle = False,
Abort = None,
pipe_abort = None,
UseNR = False,
alpha = 0.5,
plot_every_cycle = False,
x0 = None,
reset_initial_state = False,
timeout = 3600,
eps_cycle = 0.001,
eps_energy_balance = 0.01,
cycle_integrator_options = None,
max_number_of_steps = 40000,
**kwargs):
"""
This is the driving function for the PDSim model. It can be extended through the
use of the callback functions
It is highly recommended to call this function using keyword arguments like::
solve(key_inlet = 'inlet.1',
key_outlet = 'outlet.1', ....)
Parameters
----------
key_inlet : str
The key for the flow node that represents the upstream quasi-steady point
key_outlet : str
The key for the flow node that represents the upstream quasi-steady point
solver_method : str
OneCycle : bool
If ``True``, stop after just one rotation. Useful primarily for
debugging purposes
Abort : function
A function that may be called to determine whether to stop running.
If calling Abort() returns ``True``, stop running
pipe_abort :
UseNR : bool
If ``True``, use a multi-dimensional solver to determine the initial state of the state variables for each control volume
alpha : float
Use a range of ``(1-alpha)*dx, (1+alpha)*dx`` for line search if needed
plot_every_cycle : bool
If ``True``, make the plots after every cycle (primarily for debug purposes)
x0 : arraym
The starting values for the solver that modifies the discharge temperature and lump temperatures
reset_initial_state : bool
If ``True``, use the stored initial state from the previous call to ``solve`` as the starting value for the thermodynamic values for the control volumes
timeout : float
Number of seconds before the run times out
eps_cycle : float
Cycle-cycle convergence criterion
eps_energy_balance : float
Energy balance convergence criterion
cycle_integrator_options : dict
A dictionary of options to be passed to the cycle integrator
max_number_of_steps : int
Maximum number of steps allowed per rotation
Notes
-----
The callbacks ``step_callback`` and ``endcycle_callback`` and
``heat_transfer_callback`` and ``lump_energy_balance_callback`` and
``valves_callback`` should now be passed to the connect_callbacks()
function before running precond_solve() or solve()
"""
if any(cb in kwargs for cb in ['step_callback','endcycle_callback','heat_transfer_callback','lump_energy_balance_callback','valves_callback']):
raise NotImplementedError('callback functions are no longer passed to solve() function, rather they are passed to connect_callbacks() function prior to calling solve()')
# Save copies of the inlet and outlet states at the root of the HDF5 file
# for ease of retrieval
self.inlet_state = self.Tubes.Nodes[key_inlet]
self.outlet_state = self.Tubes.Nodes[key_outlet]
# Carry out some pre-run checks
self._check()
self.start_time = default_timer()
self.timeout = timeout
#Connect functions that have been serialized by saving the function name as a string
self.connect_flow_functions()
#Both inlet and outlet keys must be connected to invariant nodes -
# that is they must be part of the tubes which are all quasi-steady
if not key_inlet == None and not key_inlet in self.Tubes.Nodes:
raise KeyError('key_inlet must be a Tube node')
if not key_outlet == None and not key_outlet in self.Tubes.Nodes:
raise KeyError('key_outlet must be a Tube node')
self.key_inlet = key_inlet
self.key_outlet = key_outlet
t1=default_timer()
# Set up a pipe for accepting a value of True which will abort the run
# Used from the GUI to kill process from the top-level thread
self.pipe_abort = pipe_abort
if len(self.CVs) < 1:
raise ValueError('At least one control volume must be added using the add_CV function')
if len(self.Flows) <= 1:
raise ValueError('At least two flows must be added using the add_flow function')
# If a function called pre_solve is provided, call it with no input arguments
if hasattr(self,'pre_solve'):
self.pre_solve()
# This runs before the model starts at all
self.pre_run(N = max_number_of_steps)
# Check which method is used to do aborting
if Abort is None and pipe_abort is not None:
# Use the pipe_abort pipe to look at the abort pipe to see whether
# to quit
self.Abort = self.check_abort
elif Abort is None and pipe_abort is None:
#Disable the ability to abort, always don't abort
self.Abort = lambda : False
elif Abort is not None and pipe_abort is None:
self.Abort = Abort
else:
raise ValueError('Only one of Abort and pipe_abort may be provided')
# If you want to reset the initial state, use the values that were
# cached in the xstate_init array
if reset_initial_state is not None and reset_initial_state:
self.reset_initial_state()
self.pre_cycle(self.xstate_init)
else:
# (2) Run a cycle with the given values for the temperatures
self.pre_cycle()
self.x_state = self._get_from_matrices(0).copy()
if x0 is None:
x0 = [self.Tubes.Nodes[key_outlet].T, self.Tubes.Nodes[key_outlet].T]
# Actually run the solver
self.OBJECTIVE_CYCLE(x0, self.x_state,
cycle_integrator = solver_method,
OneCycle = OneCycle,
epsilon_energy_balance = eps_energy_balance,
epsilon_cycle = eps_cycle,
cycle_integrator_options = cycle_integrator_options,
plot_every_cycle = plot_every_cycle
)
if not self.Abort() and not OneCycle:
self.post_solve()
if hasattr(self,'resid_Td'):
del self.resid_Td
# Save the elapsed time for simulation
self.elapsed_time = default_timer() - t1
def get_prune_keys(self):
"""
Remove some elements when the simulation finishes that are not
very useful and/or are very large when stored to file
Returns
-------
prune_key_list: list
A list of HDF5 keys that are to be removed from the HDF5 file.
"""
return ['/CVs/CVs',
'/CVs/Nodes',
'/CVs/T',
'/CVs/cp',
'/CVs/cv',
'/CVs/dpdT',
'/CVs/exists_CV',
'/CVs/exists_indices',
'/CVs/exists_keys',
'/CVs/h',
'/CVs/p',
'/CVs/rho',
'/callbacks',
'/core',
'/steps',
'/theta',
'/Flows'
]
def attach_HDF5_annotations(self, fName):
"""
In this function, annotations can be attached to each HDF5 field
Parameters
----------
fName : str
The file name for the HDF5 file that is to be used
"""
attrs_dict = {
'/t':'The array of the independent variable in the solution, either time or crank angle [rad or s]',
'/m':'The NCV x Nt matrix with the mass in each control volume [kg]',
'/T':'The NCV x Nt matrix with the temperature in each control volume [K]',
'/V':'The NCV x Nt matrix with the volume in each control volume [m^3]',
'/dV':'The NCV x Nt matrix with the derivative of volume w.r.t. crank angle in each control volume [m^3/radian]',
'/h':'The NCV x Nt matrix with the enthalpy in each control volume [kJ/kg]',
'/p':'The NCV x Nt matrix with the pressure in each control volume [kPa]',
'/rho':'The NCV x Nt matrix with the density in each control volume [kg/m^3]',
'/Q':'The NCV x Nt matrix with the heat transfer TO the gas in each control volume [kW]',
'/xL':'The NCV x Nt matrix with the oil mass fraction in each control volume [-]',
'/A_shell':'The shell area of the machine [m^2]',
'/h_shell':'The heat transfer coefficient between the shell and the ambient [kW/m^2/K]',
'/key_inlet':'The key for the inlet node',
'/key_outlet':'The key for the outlet node',
'/elapsed_time':'The elapsed time for the simulation run [s]',
'/eta_a': 'Adiabatic efficiency [-]',
'/eta_oi':'Overall isentropic efficiency [-]',
'/eta_v':'Volumetric efficiency [-]',
'/Qamb':'Rate of heat transfer from the machine TO the ambient [kW]',
'/RK45_eps':'Step error tolerance for Runge-Kutta method [varied]',
'/Tamb':'Ambient temperature [K]',
'/Wdot_pv':'Mechanical power calculated as the integral of -pdV [kW]',
'/Wdot_electrical':'Electrical power of the machine [kW]',
'/Wdot_forces':'Mechanical power calculated from the mechanical analysis [kW]',
'/mdot':'Mass flow rate [kg/s]',
'/motor/eta_motor':'Motor efficiency [-]',
'/motor/losses':'Losses generated in the motor [kW]',
'/motor/suction_fraction':'Fraction of the motor losses that are added to the suction gas [-]',
'/motor/type':'The model used to simulate the motor',
'/omega':'Rotational speed [rad/s]',
'/run_index':'A unique identifier for runs in a batch'
}
hf = h5py.File(fName,'a')
for k, v in attrs_dict.items():
dataset = hf.get(k)
if dataset is None:
print('bad key',k)
else:
dataset.attrs['note'] = v
hf.close()
def post_solve(self):
"""
Do some post-processing to calculate flow rates, efficiencies, etc.
"""
#Resize all the matrices to keep only the real data
print('Ntheta is', self.Ntheta)
self.t = self.t[ 0:self.Ntheta]
self.T = self.T[:,0:self.Ntheta]
self.p = self.p[:,0:self.Ntheta]
self.Q = self.Q[:,0:self.Ntheta]
self.m = self.m[:,0:self.Ntheta]
self.rho = self.rho[:,0:self.Ntheta]
self.V = self.V[:,0:self.Ntheta]
self.dV = self.dV[:,0:self.Ntheta]
self.h = self.h[:,0:self.Ntheta]
self.xValves = self.xValves[:,0:self.Ntheta]
print('mdot*(h2-h1),P-v,Qamb', self.Wdot, self.Wdot_pv, self.Qamb)
print('Mass flow rate is',self.mdot*1000,'g/s')
print('Volumetric efficiency is',self.eta_v*100,'%')
print('Adiabatic efficiency is',self.eta_a*100,'%')
# Restructure the history for easier writing to file and more clear description of what the things are
hdisc_history = list(zip(*self.solvers.hdisc_history))
self.solvers.hdisc_history = dict(hd = np.array(hdisc_history[0]), hd_error = np.array(hdisc_history[1]))
lump_eb_history = list(zip(*self.solvers.lump_eb_history))
self.solvers.lump_eb_history = dict(Tlumps = np.array(lump_eb_history[0]), lump_eb_error = np.array(lump_eb_history[1]))
self.solvers.initial_states_history = np.array(zip(*self.solvers.initial_states_history)).T
def derivs(self, theta, x):
"""
Evaluate the derivatives of the state variables
derivs() is an internal function that should (probably) not actually be called by
any user-provided code, but is documented here for completeness.
Parameters
----------
theta : float
The value of the independent variable
x : :class:`arraym <PDSim.misc.datatypes.arraym>` instance
The array of the independent variables (state variables plus valve parameters)
Returns
-------
dfdt : :class:`arraym <PDSim.misc.datatypes.arraym>` instance
"""
# Updates the state, calculates the volumes, prepares all the things needed for derivatives
self.core.properties_and_volumes(self.CVs.exists_CV, theta, STATE_VARS_TM, x)
# Calculate the flows and sum up all the terms
self.core.calculate_flows(self.Flows)
# Calculate the heat transfer terms if provided
if self.callbacks.heat_transfer_callback is not None:
self.core.Q = arraym(self.callbacks.heat_transfer_callback(theta))
if not len(self.core.Q) == self.CVs.Nexist:
raise ValueError('Length of Q is not equal to length of number of CV in existence')
else:
self.core.Q = empty_arraym(self.CVs.Nexist)
# Calculate the derivative terms and set the derivative of the state vector
self.core.calculate_derivs(self.omega, False)
# Add the derivatives for the valves
if self.__hasValves__:
#
offset = len(self.stateVariables)*self.CVs.Nexist
for i, valve in enumerate(self.Valves):
if x[offset+2+i*2-1] < -10:
x[offset+2+i*2-1]=0.0
if x[offset+i*2] > valve.x_stopper and x[offset+2+i*2-1] > 0.0 :
x[offset+2+i*2-1]=0.0
# Get the values from the input array for this valve
xvalve = x[offset+i*2:offset+2+i*2]
# Set the values in the valve class
valve.set_xv(xvalve)
# Get the derivatives of position and derivative of velocity
self.core.property_derivs.extend(valve.derivs(self))
return self.core.property_derivs
def valves_callback(self):
"""
This is the default valves_callback function that builds the list of
derivatives of position and velocity with respect to the crank angle
It returns a :class:`list` instance with the valve return values in order
"""
#Run each valve model in turn to calculate the derivatives of the valve parameters
# for each valve
f=[]
for Valve in self.Valves:
f+=Valve.derivs(self)
return f
def IsentropicNozzleFM(self,FlowPath,A,**kwargs):
"""
A generic isentropic nozzle flow model wrapper
Parameters
----------
FlowPath : :class:`FlowPath <PDSim.flow.flow.FlowPath>` instance
A fully-instantiated flow path model
A : float
throat area for isentropic nozzle model [:math:`m^2`]
Returns
-------
mdot : float
The mass flow through the flow path [kg/s]
"""
try:
mdot = flow_models.IsentropicNozzle(A,
FlowPath.State_up,
FlowPath.State_down)
return mdot
except ZeroDivisionError:
return 0.0
def IsentropicNozzleFMSafe(self,FlowPath,A,DP_floor,**kwargs):
"""
A generic isentropic nozzle flow model wrapper with the added consideration
that if the pressure drop is below the floor value, there is no flow.
This was added to handle the case of the injection line where there is
no flow out of the injection which greatly increases the numerical
stiffness
Parameters
----------
FlowPath : :class:`FlowPath <PDSim.flow.flow.FlowPath>`
A fully-instantiated flow path model
A : float
throat area for isentropic nozzle model [:math:`m^2`]
DP_floor: float
The minimum pressure drop [kPa]
Returns
-------
mdot : float
The mass flow through the flow path [kg/s]
"""
try:
if FlowPath.State_up.p-FlowPath.State_down.p > DP_floor:
mdot = flow_models.IsentropicNozzle(A,
FlowPath.State_up,
FlowPath.State_down)
return mdot
else:
return 0.0
except ZeroDivisionError:
return 0.0
def step_callback(self,t,h,i):
""" The default step_callback which does nothing
Parameters
----------
t : float
The current value of the independent variable
h : float
The current step size
i : int
The current index
"""
return False,h
def endcycle_callback(self, eps_wrap_allowed=0.0001):
"""
This function can be called at the end of the cycle if so desired.
Its primary use is to determine whether the cycle has converged for a
given set of discharge temperatures and lump temperatures.
Parameters
----------
eps_wrap_allowed : float
Maximum error allowed, in absolute value
Returns
-------
redo : bool
``True`` if cycle should be run again with updated inputs, ``False`` otherwise.
A return value of ``True`` means that convergence of the cycle has been achieved
"""
assert self.Ntheta - 1 == self.Itheta
#old and new CV keys
LHS,RHS=[],[]
errorT,error_rho,error_mass,newT,new_rho,new_mass,oldT,old_rho,old_mass={},{},{},{},{},{},{},{},{}
for key in self.CVs.exists_keys:
# Get the 'becomes' field. If a list, parse each fork of list. If a single key convert
# into a list so you can use the same code below
if not isinstance(self.CVs[key].becomes, list):
becomes = [self.CVs[key].becomes]
else:
becomes = self.CVs[key].becomes
Iold = self.CVs.index(key)
for newkey in becomes:
# If newkey is 'none', the control volume will die at the end
# of the cycle, so just keep going
if newkey == 'none': continue
Inew = self.CVs.index(newkey)
newCV = self.CVs[newkey]
# There can't be any overlap between keys
if newkey in newT:
raise KeyError('newkey [' + newkey + '] is already in newT; becomes keys overlap but should not')
#What the state variables were at the start of the rotation
oldT[newkey]=self.T[Inew, 0]
old_rho[newkey]=self.rho[Inew, 0]
#What they are at the end of the rotation
newT[newkey]=self.T[Iold,self.Itheta]
new_rho[newkey]=self.rho[Iold,self.Itheta]
errorT[newkey]=(oldT[newkey]-newT[newkey])/newT[newkey]
error_rho[newkey]=(old_rho[newkey]-new_rho[newkey])/new_rho[newkey]
#Update the list of keys for setting the exist flags
LHS.append(key)
RHS.append(newkey)
error_T_list = [errorT[key] for key in self.CVs.keys if key in newT]
error_rho_list = [error_rho[key] for key in self.CVs.keys if key in new_rho]
new_T_list = [newT[key] for key in self.CVs.keys if key in newT]
new_rho_list = [new_rho[key] for key in self.CVs.keys if key in new_rho]
#Reset the exist flags for the CV - this should handle all the possibilities
#Turn off the LHS CV
for key in LHS:
self.CVs[key].exists=False
#Turn on the RHS CV
for key in RHS:
self.CVs[key].exists=True
self.update_existence()
# Error values are based on density and temperature independent of
# selection of state variables
error_list = []
for var in ['T','D']:
if var == 'T':
error_list += error_T_list
elif var == 'D':
error_list += error_rho_list
elif var == 'M':
error_list += error_mass_list
else:
raise KeyError
# Calculate the volumes at the beginning of the next rotation
self.core.just_volumes(self.CVs.exists_CV, 0)
V = {key:V for key,V in zip(self.CVs.exists_keys,self.core.V)}
new_mass_list = [new_rho[key]*V[key] for key in self.CVs.exists_keys]
new_list = []
for var in self.stateVariables:
if var == 'T':
new_list += new_T_list
elif var == 'D':
new_list += new_rho_list
elif var == 'M':
new_list += new_mass_list
else:
raise KeyError
# Add values for valves
for valve in self.Valves:
new_list += list(valve.get_xv())
return arraym(error_list), arraym(new_list)
def connect_flow_functions(self):
"""
Reconnect function pointers
For pickling purposes, it can sometimes be useful to just give the name
of the function relative to the PDSimCore (or derived class). If the
function is just a string, reconnect it to the function in the PDSimCore
instance
"""
for Flow in self.Flows:
if hasattr(Flow.MdotFcn, 'Function'):
if isinstance(Flow.MdotFcn.Function, six.string_types):
if hasattr(self,Flow.MdotFcn.Function):
Flow.MdotFcn.Function = getattr(self, Flow.MdotFcn.Function)
else:
raise AttributeError('The name of the function ['+Flow.MdotFcn.Function+']is not found in the PDSimCore derived class instance')
if __name__=='__main__':
PC = PDSimCore()
PC.attach_HDF5_annotations('runa.h5')
print('This is the base class that is inherited by other compressor types. Running this file doesn\'t do anything')
| 36,404
|
https://github.com/Pandinosaurus/nnabla/blob/master/examples/cpp/mnist_runtime/create_mnist_binary_inputs.py
|
Github Open Source
|
Open Source
|
Apache-2.0
| 2,023
|
nnabla
|
Pandinosaurus
|
Python
|
Code
| 232
| 574
|
# Copyright 2017,2018,2019,2020,2021 Sony Corporation.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
'''Create pgm files of MNIST images.
This must be run to create input of C++ mnist_runtime example.
'''
from __future__ import print_function
from six.moves import range
import os
import sys
import numpy as np
def main():
HERE = os.path.dirname(__file__)
# Import MNIST data
sys.path.append(
os.path.realpath(os.path.join(HERE, '..', '..', 'vision', 'mnist')))
from mnist_data import data_iterator_mnist
# Create binary output folder
path_bin = os.path.join(HERE, "mnist_images")
if not os.path.isdir(path_bin):
os.makedirs(path_bin)
# Get MNIST testing images.
images, labels = data_iterator_mnist(
10000, train=False, shuffle=True).next()
# Dump image binary files with row-major order.
for i in range(10):
outfile = os.path.join(path_bin, "{}.pgm".format(i))
print("Generator a binary file of number {} to {}".format(i, outfile))
ind = np.where(labels == i)[0][0]
image = images[ind].copy(order='C')
with open(outfile, 'w') as fd:
print('P5', file=fd)
print('# Created by nnabla mnist_runtime example.', file=fd)
print('28 28', file=fd)
print('255', file=fd)
image.tofile(fd)
if __name__ == '__main__':
main()
| 20,956
|
https://github.com/Vikram2138/Used-Car-Price-Prediction-using-MachineLearning/blob/master/app.py
|
Github Open Source
|
Open Source
|
MIT
| null |
Used-Car-Price-Prediction-using-MachineLearning
|
Vikram2138
|
Python
|
Code
| 346
| 1,627
|
from flask import Flask, request, render_template
from flask_cors import cross_origin
import pickle
app = Flask(__name__)
model = open('car.pkl','rb')
regressor = pickle.load(model)
@app.route("/")
@cross_origin()
def home():
return render_template('car.html')
@app.route("/predict", methods=["GET","POST"])
@cross_origin()
def predict():
#CAR BRAND
AMBASSADOR=0
AUDI=0
BENTLEY=0
BMW=0
CHEVROLET=0
DATSUN=0
FIAT=0
FORCE=0
FORD=0
HONDA=0
HYUNDAI=0
ISUZU=0
JAGUAR=0
JEEP=0
LAMBORGHINI=0
LAND=0
MAHINDRA=0
MARUTI=0
MERCEDES=0
MINI=0
MITSUBISHI=0
NISSAN=0
PORSCHE=0
RENAULT=0
SKODA=0
TATA=0
TOYOTA=0
VOLKSWAGEN=0
VOLVO=0
#LOCATION
Ahmedabad=0
Bangalore=0
Chennai=0
Pune=0
Mumbai=0
Coimbatore=0
Hyderabad=0
Jaipur=0
Kochi=0
Kolkata=0
Delhi=0
#FUEL
Diesel=0
LPG=0
Petrol=0
CNG=0
#TRANSMISSION
Manual=0
if request.method == 'POST':
name = request.form['Brand']
if name == 'AUDI':
AUDI=1
elif name == 'BENTLEY':
BENTLEY=1
elif name == 'BMW':
BMW=1
elif name == 'CHEVROLET':
CHEVROLET=1
elif name == 'DATSUN':
DATSUN=1
elif name == 'FIAT':
FIAT=1
elif name == 'FORCE':
FORCE=1
elif name == 'FORD':
FORD=1
elif name == 'HONDA':
HONDA=1
elif name == 'HYUNDAI':
HYUNDAI=1
elif name == 'ISUZU':
ISUZU=1
elif name == 'JAGUAR':
JAGUAR=1
elif name == 'JEEP':
JEEP=1
elif name == 'LAMBORGHINI':
LAMBORGHINI=1
elif name == 'LAND':
LAND=1
elif name == 'MAHINDRA':
MAHINDRA=1
elif name == 'MARUTI':
MARUTI=1
elif name == 'MERCEDES-BENZ':
MERCEDES=1
elif name == 'MINI':
MINI=1
elif name == 'MITSUBUSHI':
MITSUBISHI=1
elif name == 'NISSAN':
NISSAN=1
elif name == 'PORSCHE':
PORSCHE=1
elif name == 'RENAULT':
RENAULT=1
elif name == 'SKODA':
SKODA=1
elif name == 'TATA':
TATA=1
elif name == 'TOYOTA':
TOYOTA=1
elif name == 'VOLKSWAGEN':
VOLKSWAGEN=1
elif name == 'VOLVO':
VOLVO=1
else:
AMBASSADOR=1
loc = request.form['Location']
if loc=='Bangalore':
Bangalore=1
elif loc=='Chennai':
Chennai=1
elif loc=='Pune':
Pune=1
elif loc=='Mumbai':
Mumbai=1
elif loc=='Coimbatore':
Coimbatore=1
elif loc=='Hyderabad':
Hyderabad=1
elif loc=='Jaipur':
Jaipur=1
elif loc=='Kochi':
Kochi=1
elif loc=='Kolkata':
Kolkata=1
elif loc=='Delhi':
Delhi=1
else:
Ahmedabad=1
fuel = request.form['Fuel']
if fuel=='Diesel':
Diesel=1
elif fuel=='Petrol':
Petrol=1
elif fuel=='LPG':
LPG=1
else:
CNG=1
trans = request.form['Transmission']
if trans == 'Manual':
Manual=1
Year = request.form['Year']
Kms = request.form['Kms']
Own = request.form['Owner']
Mileage = request.form['Mileage']
Engine = request.form['Engine']
Power = request.form['Power']
Seat = request.form['Seats']
#PREDICTION
Price = regressor.predict([[
Year,Kms,Own,Mileage,Engine,Power,Seat,AUDI,BENTLEY,BMW,CHEVROLET,DATSUN,FIAT,FORCE,FORD,HONDA,
HYUNDAI,ISUZU,JAGUAR,JEEP,LAMBORGHINI,LAND,MAHINDRA,MARUTI,MERCEDES,MINI,MITSUBISHI,NISSAN,
PORSCHE,RENAULT,SKODA,TATA,TOYOTA,VOLKSWAGEN,VOLVO,Bangalore,Chennai,Coimbatore,Delhi,Hyderabad,
Jaipur,Kochi,Kolkata,Mumbai,Pune,Diesel,LPG,Petrol,Manual
]])
output=round(Price[0],2)
return render_template('car.html',prediction_text="Your car's price should be Rs. {} lakhs. This price may change depending on the condition of the car.".format(output))
return render_template("car.html")
if __name__ == "__main__":
app.run(debug=True)
| 20,169
|
https://github.com/redforks/thermostat/blob/master/src/keyboard.h
|
Github Open Source
|
Open Source
|
Apache-2.0
| 2,020
|
thermostat
|
redforks
|
C
|
Code
| 20
| 40
|
#pragma once
void setupKeyboard();
// key touches must polling constantly, call checkKeys() in loop() as fast as possible.
void checkKeys();
| 45,697
|
https://github.com/johnnyeven/libtools/blob/master/courier/enumeration/gen/enum_generator.go
|
Github Open Source
|
Open Source
|
Apache-2.0
| 2,019
|
libtools
|
johnnyeven
|
Go
|
Code
| 183
| 778
|
package gen
import (
"go/build"
"go/parser"
"go/types"
"path"
"path/filepath"
"golang.org/x/tools/go/loader"
"github.com/johnnyeven/libtools/codegen"
"github.com/johnnyeven/libtools/codegen/loaderx"
"github.com/johnnyeven/libtools/courier/swagger/gen"
"github.com/johnnyeven/libtools/godash"
)
type EnumGenerator struct {
Filters []string
pkgImportPath string
program *loader.Program
enumScanner *gen.EnumScanner
}
var _ interface {
codegen.Generator
} = (*EnumGenerator)(nil)
func (g *EnumGenerator) Load(cwd string) {
ldr := loader.Config{
AllowErrors: true,
ParserMode: parser.ParseComments,
}
pkgImportPath := codegen.GetPackageImportPath(cwd)
ldr.Import(pkgImportPath)
p, err := ldr.Load()
if err != nil {
panic(err)
}
g.program = p
g.pkgImportPath = pkgImportPath
g.enumScanner = gen.NewEnumScanner(p)
}
func (g *EnumGenerator) Pick() {
for pkg, pkgInfo := range g.program.AllPackages {
if pkg.Path() != g.pkgImportPath {
continue
}
for ident, obj := range pkgInfo.Defs {
if typeName, ok := obj.(*types.TypeName); ok {
doc := loaderx.CommentsOf(g.program.Fset, ident, pkgInfo.Files...)
doc, hasEnum := gen.ParseEnum(doc)
if hasEnum {
if len(g.Filters) > 0 {
if godash.StringIncludes(g.Filters, typeName.Name()) {
g.enumScanner.Enum(typeName)
}
} else {
g.enumScanner.Enum(typeName)
}
}
}
}
}
}
func (g *EnumGenerator) Output(cwd string) codegen.Outputs {
outputs := codegen.Outputs{}
for typeName, e := range g.enumScanner.Enums {
p, _ := build.Import(typeName.Pkg().Path(), "", build.FindOnly)
dir, _ := filepath.Rel(cwd, p.Dir)
enum := NewEnum(typeName.Pkg().Path(), typeName.Pkg().Name(), typeName.Name(), e, g.enumScanner.HasOffset(typeName))
outputs.Add(codegen.GeneratedSuffix(path.Join(dir, codegen.ToLowerSnakeCase(typeName.Name())+".go")), enum.String())
}
return outputs
}
| 46,893
|
https://github.com/denniscual/ombori-test/blob/master/src/baseComponents/User/ListItem.js
|
Github Open Source
|
Open Source
|
MIT
| null |
ombori-test
|
denniscual
|
JavaScript
|
Code
| 94
| 318
|
import React from 'react'
import PropTypes from 'prop-types'
import { Item } from 'semantic-ui-react'
import AvatarCircle from 'baseComponents/Avatar/Circle'
import HeaderLink from 'baseComponents/Header/Link'
import LazyLoad from 'react-lazyload'
import Placeholder from './Placeholder'
/**
* Display the information of the individual user
* Default export Component
* @function
*/
const ListItem = ({avatarURL, name}) => (
<LazyLoad height={110} offset={[-200, 0]} placeholder={<Placeholder />}>
<Item>
<AvatarCircle
style={{marginLeft: '1em'}}
url={avatarURL}
/>
<Item.Content verticalAlign='middle'>
<HeaderLink content={name} />
</Item.Content>
</Item>
</LazyLoad>
)
ListItem.defaultProps = {
avatarURL: 'https://webdgallery.com/wp-content/uploads/2014/03/Gravatar.jpg',
name: 'John Doe'
}
ListItem.propTypes = {
avatarURL: PropTypes.string.isRequired,
name: PropTypes.string.isRequired
}
export default ListItem
| 38,159
|
https://github.com/mmienko/aws-cdk-scala/blob/master/modules/cloudfront/src/main/scala/io/burkard/cdk/services/cloudfront/CustomOriginConfigProperty.scala
|
Github Open Source
|
Open Source
|
Apache-2.0
| null |
aws-cdk-scala
|
mmienko
|
Scala
|
Code
| 48
| 327
|
package io.burkard.cdk.services.cloudfront
import scala.collection.JavaConverters._
@scala.annotation.nowarn("cat=deprecation")
@SuppressWarnings(Array("org.wartremover.warts.DefaultArguments", "org.wartremover.warts.Null", "DisableSyntax.null"))
object CustomOriginConfigProperty {
def apply(
originProtocolPolicy: String,
originKeepaliveTimeout: Option[Number] = None,
httpsPort: Option[Number] = None,
originSslProtocols: Option[List[String]] = None,
originReadTimeout: Option[Number] = None,
httpPort: Option[Number] = None
): software.amazon.awscdk.services.cloudfront.CfnDistribution.CustomOriginConfigProperty =
(new software.amazon.awscdk.services.cloudfront.CfnDistribution.CustomOriginConfigProperty.Builder)
.originProtocolPolicy(originProtocolPolicy)
.originKeepaliveTimeout(originKeepaliveTimeout.orNull)
.httpsPort(httpsPort.orNull)
.originSslProtocols(originSslProtocols.map(_.asJava).orNull)
.originReadTimeout(originReadTimeout.orNull)
.httpPort(httpPort.orNull)
.build()
}
| 39,110
|
https://github.com/1130330166/Two/blob/master/app/Http/Controllers/Home/Order/OrderController.php
|
Github Open Source
|
Open Source
|
MIT
| null |
Two
|
1130330166
|
PHP
|
Code
| 977
| 7,433
|
<?php
namespace App\Http\Controllers\Home\Order;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
//引入DB类;
use DB;
class OrderController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
//展示订单页
public function index()
{
//查询分配公共导航栏分类数据
$cates = self::getCatesByPid(0);
//查询用户详情
$userinfo = DB::table('mall_home_userinfo')->where('uid','=',session('uid'))->first();
//新建数组[索引数组格式]对应订单status
$arr = ['待付款','待发货','待收货','待评价','已评价'];
/**************************************/
// 根据session uid查询该用户所有状态订单[未删除] 按下单时间降序排序
$allorder = DB::table('mall_order_info')->where('isdel','=',0)->where('uid','=',session('uid'))->orderBy("addtime","desc")->get();
//遍历该用户所用订单信息,改变时间显示,订单状态显示格式
foreach ($allorder as $key => $value) {
$allorder[$key]->addtime = date('Y/m/d H:i:s',$value->addtime);
$allorder[$key]->status = $arr[$value->status];
}
// var_dump($allorder);exit;
/**************************************/
// 根据session uid查询该用户待付款订单 status = 0 按下单时间降序排序
$unpay = DB::table('mall_order_info')->where('isdel','=',0)->where('status','=',0)->where('uid','=',session('uid'))->orderBy("addtime","desc")->get();
//遍历该用户待付款订单信息,改变时间显示,订单状态显示格式
foreach ($unpay as $key => $value) {
$unpay[$key]->addtime = date('Y/m/d H:i:s',$value->addtime);
$unpay[$key]->status = $arr[$value->status];
}
// var_dump($unpay);exit;
/**************************************/
// 根据session uid查询该用户待发货订单 status = 1 按下单时间降序排序
$unsend = DB::table('mall_order_info')->where('isdel','=',0)->where('status','=',1)->where('uid','=',session('uid'))->orderBy("addtime","desc")->get();
//遍历该用户待发货订单信息,改变时间显示,订单状态显示格式
foreach ($unsend as $key => $value) {
$unsend[$key]->addtime = date('Y/m/d H:i:s',$value->addtime);
$unsend[$key]->status = $arr[$value->status];
}
// var_dump($unsend);exit;
/**************************************/
// 根据session uid查询该用户待收货订单 status = 2 按下单时间降序排序
$waitreceipt = DB::table('mall_order_info')->where('isdel','=',0)->where('status','=',2)->where('uid','=',session('uid'))->orderBy("addtime","desc")->get();
//遍历该用户待收货订单信息,改变时间显示,订单状态显示格式
foreach ($waitreceipt as $key => $value) {
$waitreceipt[$key]->addtime = date('Y/m/d H:i:s',$value->addtime);
$waitreceipt[$key]->status = $arr[$value->status];
}
// var_dump($waitreceipt);exit;
/**************************************/
// 根据session uid查询该用户待评论订单 status = 3 按下单时间降序排序
$uncomment = DB::table('mall_order_info')->where('isdel','=',0)->where('status','=',3)->where('uid','=',session('uid'))->orderBy("addtime","desc")->get();
//遍历该用户待评论订单信息,改变时间显示,订单状态显示格式
foreach ($uncomment as $key => $value) {
$uncomment[$key]->addtime = date('Y/m/d H:i:s',$value->addtime);
$uncomment[$key]->status = $arr[$value->status];
}
// var_dump($uncomment);exit;
/**************************************/
// 根据session uid查询该用户已评论订单 status = 4 按下单时间降序排序
$commented = DB::table('mall_order_info')->where('isdel','=',0)->where('status','=',4)->where('uid','=',session('uid'))->orderBy("addtime","desc")->get();
//遍历该用户已评论订单信息,改变时间显示,订单状态显示格式
foreach ($commented as $key => $value) {
$commented[$key]->addtime = date('Y/m/d H:i:s',$value->addtime);
$commented[$key]->status = $arr[$value->status];
}
// var_dump($commented);exit;
//加载订单模板 分配数据
return view("Home.Order.index",['cates'=>$cates,'allorder'=>$allorder,'unpay'=>$unpay,'unsend'=>$unsend,'waitreceipt'=>$waitreceipt,'uncomment'=>$uncomment,'commented'=>$commented,'userinfo'=>$userinfo]);
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
// 结算页
public function create()
{
//查询分配公共导航栏分类数据
$cates = self::getCatesByPid(0);
//判断该用户购物车中是否有商品
if(DB::table('mall_cart')->where('uid','=',session('uid'))->count('gid') > 0){
//当前用户购物车内有商品
//根据session 的uid 获取当前用户的收货地址
$address = DB::table("mall_address")->where('uid','=',session('uid'))->orderBy("isdefault","desc")->get();
// var_dump($address);
//判断该用户的收货地址是否为空
if(count($address) == 0){
//该用户地址表为空,查询购物车表中的商品遍历并加载添加地址和备注的模板
//根据session('uid')[登录用户的ID]查询购物车表
$car = DB::table("mall_cart")->where("uid",'=',session('uid'))->get();
// var_dump($car);
// 购物车总价格
$total = 0;
//根据购物车商品ID查询商品信息
foreach($car as $key => $value){
// 根据商品ID查询具体商品
$goods[$key] = DB::table("mall_goods")->where('id','=',$value->gid)->first();
// 将购物车中对应商品的数量放到商品信息中
$goods[$key]->num = $value->num;
// 计算购物车总价
$total += $value->price*$value->num;
}
// var_dump($goods);exit;
// 加载模板传递数据
return view('Home.Order.emptyaddressadd',['goods'=>$goods,'total'=>$total]);
}else{
//根据session('uid')获取该用户的所有收货地址
$address = DB::table("mall_address")->where('uid','=',session('uid'))->orderBy('isdefault','desc')->get();
//根据session('uid')[登录用户的ID]查询购物车表
$car = DB::table("mall_cart")->where("uid",'=',session('uid'))->get();
// 购物车总价格
$total = 0;
//根据购物车商品ID查询商品信息
foreach($car as $key => $value){
// 根据商品ID查询具体商品
$goods[$key] = DB::table("mall_goods")->where('id','=',$value->gid)->first();
// 将购物车中对应商品的数量放到商品信息中
$goods[$key]->num = $value->num;
// 计算购物车总价
$total += $value->price*$value->num;
}
// var_dump($car);
// var_dump($address);exit;
//加载模板传递数据
return view("Home.Order.hasaddressadd",['address'=>$address,'goods'=>$goods,'total'=>$total]);
}
}else{
//当前用户购物车内没有商品,返回购物车页
return redirect('/cart');
}
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
// 生成订单,前往支付
public function store(Request $request)
{
//接收用户输入的收货信息
$arr = $request->except('beizhu','_token');
//将用户提交的收货信息添加到地址表
$arr['uid'] = session('uid');
//判断地址是否成功添加到地址表,获取插入的地址id
if($data['aid'] = DB::table("mall_address")->insertGetId($arr)){
$data['gid'] = '';
$data['num'] = '';
// 获取购物车表的信息
$car = DB::table("mall_cart")->where('uid','=',session('uid'))->get();
//遍历拼接订单gid[gid1#gid2#gid3#...] 和 购买数量num[num1#num2#num3#...]
foreach($car as $key => $value){
$data['gid'] .= $value->gid.'#';
$data['num'] .= $value->num.'#';
}
//定义订单名字
$orderName = '';
// 定义订单总价格
$data['total'] = 0;
//以商品名拼接订单名字
foreach($car as $v){
$orderName .= DB::table('mall_goods')->where('id','=',$v->gid)->first()->name;
// 订单总价
$data['total'] += $v->price*$v->num;
}
// 生成订单号
$data['oid'] = date('YmdHis',time()).rand(11111,99999);
// 生成下单时间
$data['addtime'] = time();
// 生成订单更新时间
$data['updatetime'] = time();
//生成备注
$data['beizhu'] = !empty($request->input('beizhu'))?$request->input('beizhu'):'无';
// 生成uid
$data['uid'] = session('uid');
// var_dump($data);exit;
//判断订单是否生成成功[将订单数据入库]
if(DB::table('mall_order_info')->insert($data)){
// 删除该用户的购物车数据
DB::table("mall_cart")->where("uid","=",session("uid"))->delete();
//调用支付函数跳转到支付页[订单号,订单名,支付价格,支付描述]
pay($data['oid'],$orderName,$data['total'],$data['beizhu']);
}else{
//订单生成失败跳回结算页
return back()->with("error","下单失败,请联系客服!");
}
}else{
//地址添加失败,返回上一步
return back();
}
// var_dump($data);exit;
}
//用户使用已有地址生成订单
public function makeOrderWithAddress(Request $request,$id)
{
//接收用户输入的备注信息
$data['beizhu'] = !empty($request->input('beizhu'))?$request->input('beizhu'):'';
//接收用户选择的地址ID
$data['aid'] = $id;
//获得用户ID
$data['uid'] = session('uid');
$data['gid'] = '';
$data['num'] = '';
// 获取购物车表的信息
$car = DB::table("mall_cart")->where('uid','=',session('uid'))->get();
//遍历拼接订单gid[gid1#gid2#gid3#...] 和 购买数量num[num1#num2#num3#...]
foreach($car as $key => $value){
$data['gid'] .= $value->gid.'#';
$data['num'] .= $value->num.'#';
}
//定义订单名字
$orderName = '';
// 定义订单总价格
$data['total'] = 0;
//以商品名拼接订单名字
foreach($car as $v){
$orderName .= DB::table('mall_goods')->where('id','=',$v->gid)->first()->name;
// 订单总价
$data['total'] += $v->price*$v->num;
}
// 生成订单号
$data['oid'] = date('YmdHis',time()).rand(11111,99999);
// 生成下单时间
$data['addtime'] = time();
// 生成订单更新时间
$data['updatetime'] = time();
// 生成uid
$data['uid'] = session('uid');
// var_dump($request->all());
// var_dump($data);exit;
//判断订单是否生成成功[将订单数据入库]
if(DB::table('mall_order_info')->insert($data)){
// 删除该用户的购物车数据
DB::table("mall_cart")->where("uid","=",session("uid"))->delete();
//调用支付函数跳转到支付页
pay($data['oid'],$orderName,$data['total'],$data['beizhu']);
}else{
//订单生成失败跳回结算页
return back()->with("error","下单失败,请联系客服!");
}
}
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
//订单详情页
public function show($id)
{
//判断传递过来的订单号是否属于登录的该用户[防止用户在地址栏输入不存在的订单号]
if(DB::table('mall_order_info')->where('uid','=',session('uid'))->where('oid','=',$id)->count() > 0){
//根据接收的订单ID查询订单具体信息
$data = DB::table("mall_order_info")->where("oid",'=',$id)->first();
//去除商品ID最右边的#号然后转换成数组[一个由商品ID组成的数组]
$data->gid = explode('#',rtrim($data->gid,'#'));
//去除商品数量最右边的#号然后转换成数组[一个由商品数量组成的数组]
$data->num = explode('#',rtrim($data->num,'#'));
//根据gid循环查询商品信息,存储到一个数组$arr中
for($i=0;$i<count($data->gid);$i++){
$arr[$i] = DB::table('mall_goods')->where('id','=',$data->gid[$i])->get();
}
//根据num查询商品购买数量,存储到数组$arr对应的商品信息中
for($i=0;$i<count($data->num);$i++){
$arr[$i][0]->num = $data->num[$i];
}
// dd($arr);
//将数组$arr做为订单的商品信息存储到$data中
foreach($arr as $k => $v){
//去掉商品图片路径左边的点,用于模板遍历
$v[0]->pic = ltrim($v[0]->pic,'.');
//截取商品title
$v[0]->title = mb_substr($v[0]->title, 0,30).'...';
//将商品信息存储到$data中方便遍历
$data->goodsinfo[$k] = $v[0];
}
//新建数组[索引数组格式]对应订单status
$arr = ['待付款','待发货','待收货','待评价','已评价'];
//转换订单状态显示
$data->status = $arr[$data->status];
//转换下单时间显示格式
$data->addtime = date('Y/m/d H:i:s',$data->addtime);
//根据订单信息的aid查询收货地址
$address = DB::table('mall_address')->where('id','=',$data->aid)->first();
// var_dump($address);
// dd($data);die;
/*//根据接收的订单ID===>$id连表查询订单具体信息
$data = DB::select("SELECT o.oid,o.status,o.addtime,g.pic,g.des,g.price,i.num FROM mall_order AS o,mall_goods AS g,mall_order_info AS i WHERE o.oid={$id} AND i.oid=o.oid AND i.gid=g.id");
var_dump($data);exit;*/
/*$order = DB::table("mall_order")->where('oid','=',$id)->first();
$order_info = DB::table("mall_order_info")->where('oid','=',$order->oid)->get();
// var_dump($order_info);exit;
foreach($order_info as $k => $v){
$goods[$k] = DB::table("mall_goods")->where('id','=',$v->gid)->first();
}
var_dump($order);
var_dump($order_info);
var_dump($goods);exit;*/
//加载订单详情模板
return view("Home.Order.show",['data'=>$data,'address'=>$address]);
}else{
//地址栏传递过来的订单号不属于该用户,返回
return back();
}
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
//
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
//用户修改订单状态--付款,取消订单,确认收货...
public function update(Request $request, $id)
{
//根据传递过来的订单号查询订单状态
$data = DB::table("mall_order_info")->where('oid','=',$id)->first();
//根据订单状态处理订单
if($data->status == 0){
//状态值为0,该订单未付款,跳转到付款页面
// 拼凑订单名[商品名拼接]
//去除商品ID最右边的#号然后转换成数组[一个由商品ID组成的数组]
$data->gid = explode('#',rtrim($data->gid,'#'));
//定义订单名
$orderName = '';
//遍历查询对应商品,拼接订单名
foreach($data->gid as $v){
$orderName .= DB::table("mall_goods")->where("id",'=',$v)->first()->name;
}
// 调用支付函数[订单号,订单名,支付价格,支付描述]
pay($data->oid,$orderName,$data->total,$data->beizhu);
// var_dump($orderName);
// var_dump($data);die;
}elseif($data->status == 1){
//状态值为1,等待发货无需操作
}elseif($data->status == 2){
//状态值为2,用户点击了确认收获,应更新订单状态值为3[待评价],更新时间
if(DB::table("mall_order_info")->where('oid','=',$id)->update(['status'=>3,'updatetime'=>time()])){
//如果状态更新成功,跳转回订单详情页
return back()->with("success","收货成功!");
}else{
//状态更新失败,返回订单详情页
return back();
}
}elseif($data->status == 3){
//状态值为3,用户点击了去评价,加载评价页面
//根据订单号查询对应订单信息
$orderinfo = DB::table('mall_order_info')->where('oid','=',$id)->first();
//去除商品ID最右边的#号然后转换成数组[一个由商品ID组成的数组]
$orderinfo->gid = explode('#',rtrim($orderinfo->gid,'#'));
//去除商品数量最右边的#号然后转换成数组[一个由商品数量组成的数组]
$orderinfo->num = explode('#',rtrim($orderinfo->num,'#'));
//根据gid循环查询商品信息,存储到一个数组$arr中
for($i=0;$i<count($orderinfo->gid);$i++){
$arr[$i] = DB::table('mall_goods')->where('id','=',$orderinfo->gid[$i])->get();
}
//根据num查询商品购买数量,存储到数组$arr对应的商品信息中
for($i=0;$i<count($orderinfo->num);$i++){
$arr[$i][0]->num = $orderinfo->num[$i];
}
// dd($arr);
//将数组$arr做为订单的商品信息存储到$data中
foreach($arr as $k => $v){
//去掉商品图片路径左边的点,用于模板遍历
$v[0]->pic = ltrim($v[0]->pic,'.');
//截取商品title
$v[0]->title = mb_substr($v[0]->title, 0,30).'...';
//将商品信息存储到$data中方便遍历
$orderinfo->goodsinfo[$k] = $v[0];
}
// var_dump($orderinfo);exit;
//加载评价模板 分配数据
return view("Home.Review.add",['orderinfo'=>$orderinfo]);
}elseif($data->status == 4){
//状态值为4,用户点击了提交[评价],跳转回订单页
return redirect('/homeorder');
}
// var_dump($data);exit;
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
//用户取消订单操作
public function destroy($id)
{
//将传递过来的订单id的是否删除字段赋值为1 0为正常状态 1为删除状态
if(DB::table("mall_order_info")->where('oid','=',$id)->update(['isdel'=>1,'updatetime'=>time()])){
return redirect('/homeorder')->with("success","订单已取消!");
}else{
return redirect('/homeorder')->with("error","订单取消失败,请联系客服!");
}
}
//支付宝支付成功后回调到这
public function returnUrl()
{
//获取支付成功的订单号
$oid = $_GET['out_trade_no'];
//修改订单状态
if(DB::table("mall_order_info")->where("oid","=",$oid)->update(['status'=>1,'paytime'=>time(),'updatetime'=>time()])){
return redirect("/homeorder")->with("success","付款成功,卖家正在发货!");
}else{
return redirect("/homeorder")->with("error","尊敬的客户,您已付款成功,因未知原因订单状态未被修改,抱歉给您带来不便,请联系客服发货并修改订单状态!");
}
}
//无限分类递归数据遍历
public static function getCatesByPid($pid){
$res = DB::table("mall_cates")->where("pid",'=',$pid)->get();
$data = [];
//遍历
foreach($res as $key => $value){
//获取父类的子类信息
$value->dev = self::getCatesByPid($value->id);
$data[] = $value;
}
return $data;
}
}
| 8,404
|
https://github.com/Epi-Info/Epi-Info-iOS/blob/master/EpiInfo/MainMenuMenu.h
|
Github Open Source
|
Open Source
|
Apache-2.0
| 2,023
|
Epi-Info-iOS
|
Epi-Info
|
Objective-C
|
Code
| 31
| 120
|
//
// MainMenuMenu.h
// EpiInfo
//
// Created by John Copeland on 4/20/17.
//
#import <UIKit/UIKit.h>
#import "EpiInfoViewController.h"
@interface MainMenuMenu : UIView
@property UIViewController *eivc;
@property UIButton *customKeysOptionButton;
-(void)setEncryptionKeysButtonTitle:(UIButton *)sender;
@end
| 42,056
|
https://github.com/pro-panesar/eshopstyle-server/blob/master/src/product/product.service.ts
|
Github Open Source
|
Open Source
|
MIT
| null |
eshopstyle-server
|
pro-panesar
|
TypeScript
|
Code
| 102
| 323
|
import { Injectable } from '@nestjs/common';
import { InjectModel } from '@nestjs/mongoose';
import { Model } from 'mongoose';
import { Product, ProductDoc } from './product.model';
import { v4 as uuid } from 'uuid';
@Injectable()
export class ProductService {
constructor(@InjectModel(Product.name) private ProductDoc: Model<ProductDoc>) { }
save(product: Product): Promise<Product> {
product.id = uuid();
return new this.ProductDoc(product).save();
}
find(id: string): Promise<Product> {
return this.ProductDoc.findOne({ id }).exec();
}
findByCollection(collectionName: string): Promise<Product[]> {
return this.ProductDoc.find({ collectionName }).exec();
}
findAll(): Promise<Product[]> {
return this.ProductDoc.find().exec();
}
update(product: Product): Promise<Product> {
return this.ProductDoc.updateOne({ id: product.id }, { ...product }).exec();
}
delete(id: string): Promise<boolean> {
return this.ProductDoc.deleteOne({ id }).exec();
}
}
| 12,401
|
https://github.com/bdmihai/atmega/blob/master/hw/case/dcf77-support_0.2mm_PLA_MK3S_22m.gcode
|
Github Open Source
|
Open Source
|
MIT
| null |
atmega
|
bdmihai
|
G-code
|
Code
| 20,000
| 73,390
|
; generated by PrusaSlicer 2.2.0 on 2020-05-13 at 20:48:47 UTC ; ; external perimeters extrusion width = 0.45mm ; perimeters extrusion width = 0.45mm ; infill extrusion width = 0.45mm ; solid infill extrusion width = 0.45mm ; top infill extrusion width = 0.40mm ; first layer extrusion width = 0.42mm M73 P0 R22 M73 Q0 S22 M201 X1000 Y1000 Z1000 E5000 ; sets maximum accelerations, mm/sec^2 M203 X200 Y200 Z12 E120 ; sets maximum feedrates, mm/sec M204 P1250 R1250 T1250 ; sets acceleration (P, T) and retract acceleration (R), mm/sec^2 M205 X8.00 Y8.00 Z0.40 E4.50 ; sets the jerk limits, mm/sec M205 S0 T0 ; sets the minimum extruding and travel feed rate, mm/sec M107 M862.3 P "MK3S" ; printer model check M862.1 P0.4 ; nozzle diameter check M115 U3.8.1 ; tell printer latest fw version G90 ; use absolute coordinates M83 ; extruder relative mode M104 S215 ; set extruder temp M140 S60 ; set bed temp M190 S60 ; wait for bed temp M109 S215 ; wait for extruder temp G28 W ; home all without mesh bed level G80 ; mesh bed leveling G1 Y-3.0 F1000.0 ; go outside print area G92 E0.0 G1 X60.0 E9.0 F1000.0 ; intro line M73 Q0 S22 M73 P0 R22 G1 X100.0 E12.5 F1000.0 ; intro line G92 E0.0 M221 S95 G21 ; set units to millimeters G90 ; use absolute coordinates M83 ; use relative distances for extrusion M900 K30 ; Filament gcode ;BEFORE_LAYER_CHANGE G92 E0.0 ;0.2 G1 E-0.80000 F2100.00000 G1 Z0.600 F10800.000 ;AFTER_LAYER_CHANGE ;0.2 G1 X118.991 Y93.117 G1 Z0.200 G1 E0.80000 F2100.00000 M204 S1000 G1 F1200.000 G1 X119.942 Y92.942 E0.03031 G1 X149.970 Y92.913 E0.94152 G1 X150.979 Y93.106 E0.03221 G1 X151.847 Y93.656 E0.03221 G1 X152.453 Y94.485 E0.03221 G1 X152.714 Y95.478 E0.03221 G1 X152.687 Y104.596 E0.28589 G1 X152.481 Y105.290 E0.02269 G1 X152.102 Y105.906 E0.02269 G1 X151.575 Y106.403 E0.02269 G1 X150.934 Y106.746 E0.02282 G1 X149.983 Y106.921 E0.03031 G1 X119.828 Y106.947 E0.94550 G1 X119.042 Y106.793 E0.02511 G1 X118.337 Y106.422 E0.02498 G1 X117.768 Y105.865 E0.02498 G1 X117.380 Y105.164 E0.02511 G1 X117.205 Y104.238 E0.02955 G1 X117.229 Y95.332 E0.27923 G1 X117.424 Y94.619 E0.02320 G1 X117.802 Y93.983 E0.02320 G1 X118.336 Y93.471 E0.02320 G1 X118.938 Y93.146 E0.02144 G1 X119.114 Y93.479 F10800.000 G1 F1200.000 G1 X119.946 Y93.319 E0.02657 G1 X149.970 Y93.290 E0.94136 G1 X150.844 Y93.458 E0.02790 G1 X151.597 Y93.938 E0.02802 G1 X152.119 Y94.659 E0.02790 G1 X152.339 Y95.522 E0.02790 G1 X152.319 Y104.505 E0.28167 G1 X152.143 Y105.122 E0.02012 G1 X151.810 Y105.667 E0.02000 G1 X151.345 Y106.103 E0.02000 G1 X150.777 Y106.402 E0.02012 G1 X149.978 Y106.544 E0.02543 G1 X119.860 Y106.571 E0.94435 G1 X119.174 Y106.440 E0.02190 G1 X118.556 Y106.115 E0.02190 G1 X118.059 Y105.624 E0.02190 G1 X117.724 Y105.007 E0.02201 G1 X117.582 Y104.228 E0.02484 G1 X117.600 Y95.403 E0.27667 G1 X117.767 Y94.776 E0.02036 G1 X118.100 Y94.214 E0.02048 G1 X118.570 Y93.767 E0.02036 G1 X119.061 Y93.507 E0.01741 G1 F8640.000 G1 X119.946 Y93.319 E-0.20893 G1 X122.333 Y93.317 E-0.55107 G1 E-0.04000 F2100.00000 G1 Z0.800 F10800.000 G1 X140.753 Y96.454 G1 Z0.200 G1 E0.80000 F2100.00000 G1 F1200.000 G1 X149.179 Y96.454 E0.26419 G1 X149.179 Y103.380 E0.21715 G1 X140.753 Y103.380 E0.26419 G1 X140.753 Y96.514 E0.21527 G1 X140.376 Y96.077 F10800.000 G1 F1200.000 G1 X149.556 Y96.077 E0.28783 G1 X149.556 Y103.757 E0.24080 G1 X140.376 Y103.757 E0.28783 G1 X140.376 Y96.137 E0.23892 G1 X140.765 Y96.169 F10800.000 G1 F8640.000 G1 X143.667 Y96.116 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z0.800 F10800.000 G1 X149.066 Y97.332 G1 Z0.200 G1 E0.80000 F2100.00000 G1 F1200.000 G1 X148.471 Y96.737 E0.02645 G1 X147.936 Y96.737 E0.01682 G1 X148.896 Y97.697 E0.04269 G1 X148.896 Y98.232 E0.01682 G1 X147.401 Y96.737 E0.06647 G1 X146.866 Y96.737 E0.01682 G1 X148.896 Y98.767 E0.09026 G1 X148.896 Y99.302 E0.01682 G1 X146.332 Y96.737 E0.11404 G1 X145.797 Y96.737 E0.01682 G1 X148.896 Y99.837 E0.13782 G1 X148.896 Y100.371 E0.01682 G1 X145.262 Y96.737 E0.16160 G1 X144.727 Y96.737 E0.01682 G1 X148.896 Y100.906 E0.18539 G1 X148.896 Y101.441 E0.01682 G1 X144.192 Y96.737 E0.20917 G1 X143.658 Y96.737 E0.01682 G1 X148.896 Y101.976 E0.23295 G1 X148.896 Y102.511 E0.01682 G1 X143.123 Y96.737 E0.25673 G1 X142.588 Y96.737 E0.01682 G1 X148.896 Y103.045 E0.28052 G1 X148.896 Y103.098 E0.00164 G1 X148.413 Y103.098 E0.01518 G1 X142.053 Y96.737 E0.28284 G1 X141.518 Y96.737 E0.01682 G1 X147.879 Y103.098 E0.28284 G1 X147.344 Y103.098 E0.01682 G1 X141.036 Y96.790 E0.28051 G1 X141.036 Y97.324 E0.01682 G1 X146.809 Y103.098 E0.25673 G1 X146.274 Y103.098 E0.01682 G1 X141.036 Y97.859 E0.23295 G1 X141.036 Y98.394 E0.01682 G1 X145.739 Y103.098 E0.20916 G1 X145.205 Y103.098 E0.01682 G1 X141.036 Y98.929 E0.18538 G1 X141.036 Y99.464 E0.01682 G1 X144.670 Y103.098 E0.16160 G1 X144.135 Y103.098 E0.01682 G1 X141.036 Y99.998 E0.13782 G1 X141.036 Y100.533 E0.01682 G1 X143.600 Y103.098 E0.11403 G1 X143.065 Y103.098 E0.01682 G1 X141.036 Y101.068 E0.09025 G1 X141.036 Y101.603 E0.01682 G1 X142.531 Y103.098 E0.06647 G1 X141.996 Y103.098 E0.01682 G1 X141.036 Y102.138 E0.04269 G1 X141.036 Y102.672 E0.01682 G1 X141.631 Y103.267 E0.02645 G1 F8640.000 G1 X141.036 Y102.672 E-0.19422 G1 X141.036 Y102.138 E-0.12349 G1 X141.996 Y103.098 E-0.31345 G1 X142.531 Y103.098 E-0.12349 G1 X142.514 Y103.081 E-0.00534 G1 E-0.04000 F2100.00000 G1 Z0.800 F10800.000 G1 X129.172 Y103.267 G1 Z0.200 G1 E0.80000 F2100.00000 G1 F1200.000 G1 X129.172 Y103.409 E0.00445 G1 X120.746 Y103.409 E0.26419 G1 X120.746 Y96.483 E0.21715 G1 X129.172 Y96.483 E0.26419 G1 X129.172 Y103.207 E0.21083 G1 X129.549 Y103.786 F10800.000 G1 F1200.000 G1 X120.369 Y103.786 E0.28783 G1 X120.369 Y96.106 E0.24080 G1 X129.549 Y96.106 E0.28783 G1 X129.549 Y103.726 E0.23892 G1 X129.160 Y103.694 F10800.000 G1 F8640.000 G1 X126.257 Y103.748 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z0.800 F10800.000 G1 X121.624 Y103.296 G1 Z0.200 G1 E0.80000 F2100.00000 G1 F1200.000 G1 X121.029 Y102.701 E0.02645 G1 X121.029 Y102.166 E0.01682 G1 X121.989 Y103.126 E0.04269 G1 X122.523 Y103.126 E0.01682 G1 X121.029 Y101.631 E0.06647 G1 X121.029 Y101.097 E0.01682 G1 X123.058 Y103.126 E0.09025 G1 X123.593 Y103.126 E0.01682 G1 X121.029 Y100.562 E0.11403 G1 X121.029 Y100.027 E0.01682 G1 X124.128 Y103.126 E0.13782 G1 X124.663 Y103.126 E0.01682 G1 X121.029 Y99.492 E0.16160 G1 X121.029 Y98.957 E0.01682 G1 X125.197 Y103.126 E0.18538 G1 X125.732 Y103.126 E0.01682 G1 X121.029 Y98.423 E0.20916 G1 X121.029 Y97.888 E0.01682 G1 X126.267 Y103.126 E0.23295 G1 X126.802 Y103.126 E0.01682 G1 X121.029 Y97.353 E0.25673 G1 X121.029 Y96.818 E0.01682 G1 X127.337 Y103.126 E0.28051 G1 X127.872 Y103.126 E0.01682 G1 X121.511 Y96.766 E0.28284 G1 X122.046 Y96.766 E0.01682 G1 X128.406 Y103.126 E0.28284 G1 X128.889 Y103.126 E0.01518 G1 X128.889 Y103.074 E0.00164 G1 X122.581 Y96.766 E0.28052 G1 X123.116 Y96.766 E0.01682 G1 X128.889 Y102.539 E0.25673 G1 X128.889 Y102.004 E0.01682 G1 X123.650 Y96.766 E0.23295 G1 X124.185 Y96.766 E0.01682 G1 X128.889 Y101.470 E0.20917 G1 X128.889 Y100.935 E0.01682 G1 X124.720 Y96.766 E0.18539 G1 X125.255 Y96.766 E0.01682 G1 X128.889 Y100.400 E0.16160 G1 X128.889 Y99.865 E0.01682 G1 X125.790 Y96.766 E0.13782 G1 X126.325 Y96.766 E0.01682 G1 X128.889 Y99.330 E0.11404 G1 X128.889 Y98.796 E0.01682 G1 X126.859 Y96.766 E0.09026 G1 X127.394 Y96.766 E0.01682 G1 X128.889 Y98.261 E0.06647 G1 X128.889 Y97.726 E0.01682 G1 X127.929 Y96.766 E0.04269 G1 X128.464 Y96.766 E0.01682 G1 X129.059 Y97.361 E0.02645 M106 S255 ;BEFORE_LAYER_CHANGE G92 E0.0 ;0.4 G1 F8640.000 G1 X128.464 Y96.766 E-0.19426 G1 X127.929 Y96.766 E-0.12349 G1 X128.889 Y97.726 E-0.31349 G1 X128.889 Y98.261 E-0.12349 G1 X128.873 Y98.245 E-0.00528 G1 E-0.04000 F2100.00000 G1 Z0.800 F10800.000 ;AFTER_LAYER_CHANGE ;0.4 M104 S210 ; set temperature G1 X152.453 Y94.485 G1 Z0.400 G1 E0.80000 F2100.00000 G1 F2073 G1 X152.714 Y95.478 E0.03221 G1 X152.687 Y104.596 E0.28589 G1 X152.481 Y105.290 E0.02269 G1 X152.102 Y105.906 E0.02269 G1 X151.575 Y106.403 E0.02269 G1 X150.934 Y106.746 E0.02282 G1 X149.983 Y106.921 E0.03031 G1 X119.828 Y106.947 E0.94550 G1 X119.042 Y106.793 E0.02511 G1 X118.337 Y106.422 E0.02498 G1 X117.768 Y105.865 E0.02498 G1 X117.380 Y105.164 E0.02511 G1 X117.205 Y104.238 E0.02955 G1 X117.229 Y95.332 E0.27923 G1 X117.424 Y94.619 E0.02320 G1 X117.802 Y93.983 E0.02320 G1 X118.336 Y93.471 E0.02320 G1 X118.991 Y93.117 E0.02333 G1 X119.942 Y92.942 E0.03031 G1 X149.970 Y92.913 E0.94152 G1 X150.979 Y93.106 E0.03221 G1 X151.847 Y93.656 E0.03221 G1 X152.418 Y94.436 E0.03032 G1 X152.115 Y94.655 F10800.000 G1 F2073 G1 X152.339 Y95.522 E0.02806 G1 X152.319 Y104.505 E0.28167 G1 X152.143 Y105.122 E0.02012 G1 X151.810 Y105.667 E0.02000 G1 X151.345 Y106.103 E0.02000 G1 X150.777 Y106.402 E0.02012 G1 X149.978 Y106.544 E0.02543 G1 X119.860 Y106.571 E0.94435 G1 X119.174 Y106.440 E0.02190 G1 X118.556 Y106.115 E0.02190 G1 X118.059 Y105.624 E0.02190 G1 X117.724 Y105.007 E0.02201 G1 X117.582 Y104.228 E0.02484 G1 X117.600 Y95.403 E0.27667 G1 X117.767 Y94.776 E0.02036 G1 X118.100 Y94.214 E0.02048 G1 X118.570 Y93.767 E0.02036 G1 X119.148 Y93.462 E0.02048 G1 X119.946 Y93.319 E0.02543 G1 X149.970 Y93.290 E0.94136 G1 X150.844 Y93.458 E0.02790 G1 X151.597 Y93.938 E0.02802 G1 X152.080 Y94.606 E0.02584 G1 F8640.000 G1 X152.339 Y95.522 E-0.21962 G1 X152.333 Y97.862 E-0.54038 G1 E-0.04000 F2100.00000 G1 Z1.000 F10800.000 G1 X149.334 Y96.299 G1 Z0.400 G1 E0.80000 F2100.00000 M204 S800 G1 F1500.000 G1 X149.334 Y103.535 E0.24492 G1 X140.598 Y103.535 E0.29570 G1 X140.598 Y96.299 E0.24492 G1 X149.274 Y96.299 E0.29367 M204 S1000 G1 X149.741 Y95.892 F10800.000 M204 S800 G1 F1500.000 G1 X149.741 Y103.942 E0.27248 G1 X140.191 Y103.942 E0.32326 G1 X140.191 Y95.892 E0.27248 G1 X149.681 Y95.892 E0.32123 M204 S1000 G1 X149.627 Y96.276 F10800.000 G1 F8640.000 G1 X149.705 Y99.184 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z1.000 F10800.000 G1 X141.544 Y96.422 G1 Z0.400 G1 E0.80000 F2100.00000 G1 F2073 G1 X140.903 Y97.062 E0.03071 G1 X140.903 Y97.639 E0.01954 G1 X141.937 Y96.605 E0.04956 G1 X142.514 Y96.605 E0.01954 G1 X140.903 Y98.215 E0.07720 G1 X140.903 Y98.792 E0.01954 G1 X143.090 Y96.605 E0.10483 G1 X143.667 Y96.605 E0.01954 G1 X140.903 Y99.368 E0.13246 G1 X140.903 Y99.945 E0.01954 G1 X144.243 Y96.605 E0.16009 G1 X144.820 Y96.605 E0.01954 G1 X140.903 Y100.521 E0.18772 G1 X140.903 Y101.098 E0.01954 G1 X145.396 Y96.605 E0.21536 G1 X145.973 Y96.605 E0.01954 G1 X140.903 Y101.674 E0.24299 G1 X140.903 Y102.251 E0.01954 G1 X146.549 Y96.605 E0.27062 G1 X147.126 Y96.605 E0.01954 G1 X140.903 Y102.827 E0.29825 G1 X140.903 Y103.230 E0.01366 G1 X141.077 Y103.230 E0.00588 G1 X147.702 Y96.605 E0.31757 G1 X148.279 Y96.605 E0.01954 G1 X141.653 Y103.230 E0.31757 G1 X142.230 Y103.230 E0.01954 G1 X148.855 Y96.605 E0.31757 G1 X149.029 Y96.605 E0.00588 G1 X149.029 Y97.008 E0.01366 G1 X142.806 Y103.230 E0.29826 G1 X143.383 Y103.230 E0.01954 G1 X149.029 Y97.584 E0.27063 G1 X149.029 Y98.161 E0.01954 G1 X143.959 Y103.230 E0.24299 G1 X144.536 Y103.230 E0.01954 G1 X149.029 Y98.737 E0.21536 G1 X149.029 Y99.314 E0.01954 G1 X145.112 Y103.230 E0.18773 G1 X145.689 Y103.230 E0.01954 G1 X149.029 Y99.890 E0.16010 G1 X149.029 Y100.466 E0.01954 G1 X146.265 Y103.230 E0.13247 G1 X146.841 Y103.230 E0.01954 G1 X149.029 Y101.043 E0.10483 G1 X149.029 Y101.619 E0.01954 G1 X147.418 Y103.230 E0.07720 G1 X147.994 Y103.230 E0.01954 G1 X149.029 Y102.196 E0.04957 G1 X149.029 Y102.772 E0.01954 G1 X148.388 Y103.413 E0.03072 G1 F8640.000 G1 X149.029 Y102.772 E-0.20928 G1 X149.029 Y102.196 E-0.13311 G1 X147.994 Y103.230 E-0.33770 G1 X147.648 Y103.230 E-0.07992 G1 E-0.04000 F2100.00000 G1 Z1.000 F10800.000 G1 X129.327 Y103.413 G1 Z0.400 G1 E0.80000 F2100.00000 M204 S800 G1 F1500.000 G1 X129.327 Y103.564 E0.00510 G1 X120.591 Y103.564 E0.29570 G1 X120.591 Y96.328 E0.24492 G1 X129.327 Y96.328 E0.29570 G1 X129.327 Y103.353 E0.23779 M204 S1000 G1 X129.734 Y103.971 F10800.000 M204 S800 G1 F1500.000 G1 X120.184 Y103.971 E0.32326 G1 X120.184 Y95.921 E0.27248 G1 X129.734 Y95.921 E0.32326 G1 X129.734 Y103.911 E0.27045 M204 S1000 G1 X129.345 Y103.879 F10800.000 G1 F8640.000 G1 X126.442 Y103.932 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z1.000 F10800.000 G1 X121.537 Y96.450 G1 Z0.400 G1 E0.80000 F2100.00000 G1 F2073 G1 X120.896 Y97.091 E0.03071 G1 X120.896 Y97.667 E0.01954 G1 X121.930 Y96.633 E0.04956 G1 X122.507 Y96.633 E0.01954 G1 X120.896 Y98.244 E0.07720 G1 X120.896 Y98.820 E0.01954 G1 X123.083 Y96.633 E0.10483 G1 X123.660 Y96.633 E0.01954 G1 X120.896 Y99.397 E0.13246 G1 X120.896 Y99.973 E0.01954 G1 X124.236 Y96.633 E0.16009 G1 X124.813 Y96.633 E0.01954 G1 X120.896 Y100.550 E0.18772 G1 X120.896 Y101.126 E0.01954 G1 X125.389 Y96.633 E0.21536 G1 X125.966 Y96.633 E0.01954 G1 X120.896 Y101.703 E0.24299 G1 X120.896 Y102.279 E0.01954 G1 X126.542 Y96.633 E0.27062 G1 X127.118 Y96.633 E0.01954 G1 X120.896 Y102.856 E0.29825 G1 X120.896 Y103.259 E0.01366 G1 X121.070 Y103.259 E0.00588 G1 X127.695 Y96.633 E0.31757 G1 X128.271 Y96.633 E0.01954 G1 X121.646 Y103.259 E0.31757 G1 X122.223 Y103.259 E0.01954 G1 X128.848 Y96.633 E0.31757 G1 X129.021 Y96.633 E0.00588 G1 X129.021 Y97.036 E0.01366 G1 X122.799 Y103.259 E0.29826 G1 X123.376 Y103.259 E0.01954 G1 X129.021 Y97.613 E0.27063 G1 X129.021 Y98.189 E0.01954 G1 X123.952 Y103.259 E0.24299 G1 X124.528 Y103.259 E0.01954 G1 X129.021 Y98.766 E0.21536 G1 X129.021 Y99.342 E0.01954 G1 X125.105 Y103.259 E0.18773 G1 X125.681 Y103.259 E0.01954 G1 X129.021 Y99.919 E0.16010 M73 Q4 S21 G1 X129.021 Y100.495 E0.01954 G1 X126.258 Y103.259 E0.13247 G1 X126.834 Y103.259 E0.01954 G1 X129.021 Y101.072 E0.10483 G1 X129.021 Y101.648 E0.01954 G1 X127.411 Y103.259 E0.07720 M73 P4 R21 G1 X127.987 Y103.259 E0.01954 G1 X129.021 Y102.225 E0.04957 G1 X129.021 Y102.801 E0.01954 G1 X128.381 Y103.442 E0.03072 ;BEFORE_LAYER_CHANGE G92 E0.0 ;0.6 G1 F8640.000 G1 X129.021 Y102.801 E-0.20928 G1 X129.021 Y102.225 E-0.13311 G1 X127.987 Y103.259 E-0.33770 G1 X127.641 Y103.259 E-0.07992 G1 E-0.04000 F2100.00000 G1 Z1.000 F10800.000 ;AFTER_LAYER_CHANGE ;0.6 G1 X152.453 Y94.485 G1 Z0.600 G1 E0.80000 F2100.00000 G1 F2077 G1 X152.714 Y95.478 E0.03221 G1 X152.687 Y104.596 E0.28589 G1 X152.481 Y105.290 E0.02269 G1 X152.102 Y105.906 E0.02269 G1 X151.575 Y106.403 E0.02269 G1 X150.934 Y106.746 E0.02282 G1 X149.983 Y106.921 E0.03031 G1 X119.828 Y106.947 E0.94550 G1 X119.042 Y106.793 E0.02511 G1 X118.337 Y106.422 E0.02498 G1 X117.768 Y105.865 E0.02498 G1 X117.380 Y105.164 E0.02511 G1 X117.205 Y104.238 E0.02955 G1 X117.229 Y95.332 E0.27923 G1 X117.424 Y94.619 E0.02320 G1 X117.802 Y93.983 E0.02320 G1 X118.336 Y93.471 E0.02320 G1 X118.991 Y93.117 E0.02333 G1 X119.942 Y92.942 E0.03031 G1 X149.970 Y92.913 E0.94152 G1 X150.979 Y93.106 E0.03221 G1 X151.847 Y93.656 E0.03221 G1 X152.418 Y94.436 E0.03032 G1 X152.115 Y94.655 F10800.000 G1 F2077 G1 X152.339 Y95.522 E0.02806 G1 X152.319 Y104.505 E0.28167 G1 X152.143 Y105.122 E0.02012 G1 X151.810 Y105.667 E0.02000 G1 X151.345 Y106.103 E0.02000 G1 X150.777 Y106.402 E0.02012 G1 X149.978 Y106.544 E0.02543 G1 X119.860 Y106.571 E0.94435 G1 X119.174 Y106.440 E0.02190 G1 X118.556 Y106.115 E0.02190 G1 X118.059 Y105.624 E0.02190 G1 X117.724 Y105.007 E0.02201 G1 X117.582 Y104.228 E0.02484 G1 X117.600 Y95.403 E0.27667 G1 X117.767 Y94.776 E0.02036 G1 X118.100 Y94.214 E0.02048 G1 X118.570 Y93.767 E0.02036 G1 X119.148 Y93.462 E0.02048 G1 X119.946 Y93.319 E0.02543 G1 X149.970 Y93.290 E0.94136 G1 X150.844 Y93.458 E0.02790 G1 X151.597 Y93.938 E0.02802 G1 X152.080 Y94.606 E0.02584 G1 F8640.000 G1 X152.339 Y95.522 E-0.21962 G1 X152.333 Y97.862 E-0.54038 G1 E-0.04000 F2100.00000 G1 Z1.200 F10800.000 G1 X149.334 Y96.299 G1 Z0.600 G1 E0.80000 F2100.00000 M204 S800 G1 F1500.000 G1 X149.334 Y103.535 E0.24492 G1 X140.598 Y103.535 E0.29570 G1 X140.598 Y96.299 E0.24492 G1 X149.274 Y96.299 E0.29367 M204 S1000 G1 X149.741 Y95.892 F10800.000 M204 S800 G1 F1500.000 G1 X149.741 Y103.942 E0.27248 G1 X140.191 Y103.942 E0.32326 G1 X140.191 Y95.892 E0.27248 G1 X149.681 Y95.892 E0.32123 M204 S1000 G1 X149.627 Y96.276 F10800.000 G1 F8640.000 G1 X149.705 Y99.184 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z1.200 F10800.000 G1 X140.720 Y102.589 G1 Z0.600 G1 E0.80000 F2100.00000 G1 F2077 G1 X141.361 Y103.230 E0.03071 G1 X141.937 Y103.230 E0.01954 G1 X140.903 Y102.196 E0.04956 G1 X140.903 Y101.619 E0.01954 G1 X142.514 Y103.230 E0.07720 G1 X143.090 Y103.230 E0.01954 G1 X140.903 Y101.043 E0.10483 G1 X140.903 Y100.467 E0.01954 G1 X143.667 Y103.230 E0.13246 G1 X144.243 Y103.230 E0.01954 G1 X140.903 Y99.890 E0.16009 G1 X140.903 Y99.314 E0.01954 G1 X144.820 Y103.230 E0.18772 G1 X145.396 Y103.230 E0.01954 G1 X140.903 Y98.737 E0.21536 G1 X140.903 Y98.161 E0.01954 G1 X145.973 Y103.230 E0.24299 G1 X146.549 Y103.230 E0.01954 G1 X140.903 Y97.584 E0.27062 G1 X140.903 Y97.008 E0.01954 G1 X147.126 Y103.230 E0.29825 G1 X147.702 Y103.230 E0.01954 G1 X141.077 Y96.605 E0.31757 G1 X141.653 Y96.605 E0.01954 G1 X148.279 Y103.230 E0.31757 G1 X148.855 Y103.230 E0.01954 G1 X142.230 Y96.605 E0.31757 G1 X142.806 Y96.605 E0.01954 G1 X149.029 Y102.827 E0.29826 G1 X149.029 Y102.251 E0.01954 G1 X143.383 Y96.605 E0.27063 G1 X143.959 Y96.605 E0.01954 G1 X149.029 Y101.674 E0.24299 G1 X149.029 Y101.098 E0.01954 G1 X144.536 Y96.605 E0.21536 G1 X145.112 Y96.605 E0.01954 G1 X149.029 Y100.521 E0.18773 G1 X149.029 Y99.945 E0.01954 G1 X145.689 Y96.605 E0.16010 G1 X146.265 Y96.605 E0.01954 G1 X149.029 Y99.368 E0.13247 G1 X149.029 Y98.792 E0.01954 G1 X146.841 Y96.605 E0.10483 G1 X147.418 Y96.605 E0.01954 G1 X149.029 Y98.215 E0.07720 G1 X149.029 Y97.639 E0.01954 G1 X147.994 Y96.605 E0.04957 G1 X148.571 Y96.605 E0.01954 G1 X149.212 Y97.246 E0.03072 G1 F8640.000 G1 X148.571 Y96.605 E-0.20928 G1 X147.994 Y96.605 E-0.13311 G1 X149.029 Y97.639 E-0.33770 G1 X149.029 Y97.985 E-0.07992 G1 E-0.04000 F2100.00000 G1 Z1.200 F10800.000 G1 X129.327 Y96.328 G1 Z0.600 G1 E0.80000 F2100.00000 M204 S800 G1 F1500.000 G1 X129.327 Y103.564 E0.24492 G1 X120.591 Y103.564 E0.29570 G1 X120.591 Y96.328 E0.24492 G1 X129.267 Y96.328 E0.29367 M204 S1000 G1 X129.734 Y95.921 F10800.000 M204 S800 G1 F1500.000 G1 X129.734 Y103.971 E0.27248 G1 X120.184 Y103.971 E0.32326 G1 X120.184 Y95.921 E0.27248 G1 X129.674 Y95.921 E0.32123 M204 S1000 G1 X129.619 Y96.304 F10800.000 G1 F8640.000 G1 X129.698 Y99.212 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z1.200 F10800.000 G1 X120.713 Y102.618 G1 Z0.600 G1 E0.80000 F2100.00000 G1 F2077 G1 X121.354 Y103.259 E0.03071 G1 X121.930 Y103.259 E0.01954 G1 X120.896 Y102.225 E0.04956 G1 X120.896 Y101.648 E0.01954 G1 X122.507 Y103.259 E0.07720 G1 X123.083 Y103.259 E0.01954 G1 X120.896 Y101.072 E0.10483 G1 X120.896 Y100.495 E0.01954 G1 X123.660 Y103.259 E0.13246 G1 X124.236 Y103.259 E0.01954 G1 X120.896 Y99.919 E0.16009 G1 X120.896 Y99.342 E0.01954 G1 X124.813 Y103.259 E0.18772 G1 X125.389 Y103.259 E0.01954 G1 X120.896 Y98.766 E0.21536 G1 X120.896 Y98.189 E0.01954 G1 X125.966 Y103.259 E0.24299 G1 X126.542 Y103.259 E0.01954 G1 X120.896 Y97.613 E0.27062 G1 X120.896 Y97.036 E0.01954 G1 X127.118 Y103.259 E0.29825 G1 X127.695 Y103.259 E0.01954 G1 X121.070 Y96.633 E0.31757 G1 X121.646 Y96.633 E0.01954 G1 X128.271 Y103.259 E0.31757 G1 X128.848 Y103.259 E0.01954 G1 X122.223 Y96.633 E0.31757 G1 X122.799 Y96.633 E0.01954 G1 X129.021 Y102.856 E0.29826 G1 X129.021 Y102.279 E0.01954 G1 X123.376 Y96.633 E0.27063 G1 X123.952 Y96.633 E0.01954 G1 X129.021 Y101.703 E0.24299 G1 X129.021 Y101.126 E0.01954 G1 X124.528 Y96.633 E0.21536 G1 X125.105 Y96.633 E0.01954 G1 X129.021 Y100.550 E0.18773 G1 X129.021 Y99.973 E0.01954 G1 X125.681 Y96.633 E0.16010 G1 X126.258 Y96.633 E0.01954 G1 X129.021 Y99.397 E0.13247 G1 X129.021 Y98.821 E0.01954 G1 X126.834 Y96.633 E0.10483 G1 X127.411 Y96.633 E0.01954 G1 X129.021 Y98.244 E0.07720 G1 X129.021 Y97.668 E0.01954 G1 X127.987 Y96.633 E0.04957 G1 X128.564 Y96.633 E0.01954 G1 X129.205 Y97.274 E0.03072 ;BEFORE_LAYER_CHANGE G92 E0.0 ;0.8 G1 F8640.000 G1 X128.564 Y96.633 E-0.20928 G1 X127.987 Y96.633 E-0.13311 G1 X129.021 Y97.668 E-0.33770 G1 X129.021 Y98.014 E-0.07992 G1 E-0.04000 F2100.00000 G1 Z1.200 F10800.000 ;AFTER_LAYER_CHANGE ;0.8 G1 X140.598 Y96.299 G1 Z0.800 G1 E0.80000 F2100.00000 M204 S800 G1 F1320 G1 X149.334 Y96.299 E0.29570 G1 X149.334 Y103.535 E0.24492 G1 X140.598 Y103.535 E0.29570 G1 X140.598 Y96.359 E0.24289 M204 S1000 G1 X140.191 Y95.892 F10800.000 M204 S800 G1 F1320 G1 X149.741 Y95.892 E0.32326 G1 X149.741 Y103.942 E0.27248 G1 X140.191 Y103.942 E0.32326 G1 X140.191 Y95.952 E0.27045 M204 S1000 G1 X140.580 Y95.985 F10800.000 G1 F8640.000 G1 X143.482 Y95.932 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z1.400 F10800.000 G1 X148.388 Y103.413 G1 Z0.800 G1 E0.80000 F2100.00000 G1 F1320 G1 X149.029 Y102.772 E0.03072 G1 X149.029 Y102.196 E0.01954 G1 X147.994 Y103.230 E0.04957 G1 X147.418 Y103.230 E0.01954 G1 X149.029 Y101.619 E0.07720 G1 X149.029 Y101.043 E0.01954 G1 X146.841 Y103.230 E0.10483 G1 X146.265 Y103.230 E0.01954 G1 X149.029 Y100.466 E0.13247 G1 X149.029 Y99.890 E0.01954 G1 X145.689 Y103.230 E0.16010 G1 X145.112 Y103.230 E0.01954 G1 X149.029 Y99.314 E0.18773 G1 X149.029 Y98.737 E0.01954 G1 X144.536 Y103.230 E0.21536 G1 X143.959 Y103.230 E0.01954 G1 X149.029 Y98.161 E0.24299 G1 X149.029 Y97.584 E0.01954 G1 X143.383 Y103.230 E0.27063 G1 X142.806 Y103.230 E0.01954 G1 X149.029 Y97.008 E0.29826 G1 X149.029 Y96.605 E0.01366 G1 X148.855 Y96.605 E0.00588 G1 X142.230 Y103.230 E0.31757 G1 X141.653 Y103.230 E0.01954 G1 X148.279 Y96.605 E0.31757 G1 X147.702 Y96.605 E0.01954 G1 X141.077 Y103.230 E0.31757 G1 X140.903 Y103.230 E0.00588 G1 X140.903 Y102.827 E0.01366 G1 X147.126 Y96.605 E0.29825 G1 X146.549 Y96.605 E0.01954 G1 X140.903 Y102.251 E0.27062 G1 X140.903 Y101.674 E0.01954 G1 X145.973 Y96.605 E0.24299 G1 X145.396 Y96.605 E0.01954 G1 X140.903 Y101.098 E0.21536 G1 X140.903 Y100.521 E0.01954 G1 X144.820 Y96.605 E0.18772 G1 X144.243 Y96.605 E0.01954 G1 X140.903 Y99.945 E0.16009 G1 X140.903 Y99.368 E0.01954 G1 X143.667 Y96.605 E0.13246 G1 X143.090 Y96.605 E0.01954 G1 X140.903 Y98.792 E0.10483 G1 X140.903 Y98.215 E0.01954 G1 X142.514 Y96.605 E0.07720 G1 X141.937 Y96.605 E0.01954 G1 X140.903 Y97.639 E0.04956 G1 X140.903 Y97.062 E0.01954 G1 X141.544 Y96.422 E0.03071 G1 F8640.000 G1 X140.903 Y97.062 E-0.20924 G1 X140.903 Y97.639 E-0.13311 G1 X141.937 Y96.605 E-0.33766 G1 X142.284 Y96.605 E-0.07999 G1 E-0.04000 F2100.00000 G1 Z1.400 F10800.000 G1 X129.327 Y96.422 G1 Z0.800 G1 E0.80000 F2100.00000 M204 S800 G1 F1320 G1 X129.327 Y103.564 E0.24176 G1 X120.591 Y103.564 E0.29570 G1 X120.591 Y96.328 E0.24492 G1 X129.327 Y96.328 E0.29570 G1 X129.327 Y96.362 E0.00113 M204 S1000 G1 X129.734 Y95.921 F10800.000 M204 S800 G1 F1320 G1 X129.734 Y103.971 E0.27248 G1 X120.184 Y103.971 E0.32326 G1 X120.184 Y95.921 E0.27248 G1 X129.674 Y95.921 E0.32123 M204 S1000 G1 X129.619 Y96.304 F10800.000 G1 F8640.000 G1 X129.698 Y99.212 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z1.400 F10800.000 G1 X121.537 Y96.450 G1 Z0.800 G1 E0.80000 F2100.00000 G1 F1320 G1 X120.896 Y97.091 E0.03071 G1 X120.896 Y97.667 E0.01954 G1 X121.930 Y96.633 E0.04956 G1 X122.507 Y96.633 E0.01954 G1 X120.896 Y98.244 E0.07720 G1 X120.896 Y98.820 E0.01954 G1 X123.083 Y96.633 E0.10483 G1 X123.660 Y96.633 E0.01954 G1 X120.896 Y99.397 E0.13246 G1 X120.896 Y99.973 E0.01954 G1 X124.236 Y96.633 E0.16009 G1 X124.813 Y96.633 E0.01954 G1 X120.896 Y100.550 E0.18772 G1 X120.896 Y101.126 E0.01954 G1 X125.389 Y96.633 E0.21536 G1 X125.966 Y96.633 E0.01954 G1 X120.896 Y101.703 E0.24299 G1 X120.896 Y102.279 E0.01954 G1 X126.542 Y96.633 E0.27062 G1 X127.118 Y96.633 E0.01954 G1 X120.896 Y102.856 E0.29825 G1 X120.896 Y103.259 E0.01366 G1 X121.070 Y103.259 E0.00588 G1 X127.695 Y96.633 E0.31757 G1 X128.271 Y96.633 E0.01954 G1 X121.646 Y103.259 E0.31757 G1 X122.223 Y103.259 E0.01954 G1 X128.848 Y96.633 E0.31757 G1 X129.021 Y96.633 E0.00588 G1 X129.021 Y97.036 E0.01366 G1 X122.799 Y103.259 E0.29826 G1 X123.376 Y103.259 E0.01954 G1 X129.021 Y97.613 E0.27063 G1 X129.021 Y98.189 E0.01954 G1 X123.952 Y103.259 E0.24299 G1 X124.528 Y103.259 E0.01954 G1 X129.021 Y98.766 E0.21536 G1 X129.021 Y99.342 E0.01954 G1 X125.105 Y103.259 E0.18773 G1 X125.681 Y103.259 E0.01954 G1 X129.021 Y99.919 E0.16010 G1 X129.021 Y100.495 E0.01954 G1 X126.258 Y103.259 E0.13247 G1 X126.834 Y103.259 E0.01954 G1 X129.021 Y101.072 E0.10483 G1 X129.021 Y101.648 E0.01954 G1 X127.411 Y103.259 E0.07720 G1 X127.987 Y103.259 E0.01954 G1 X129.021 Y102.225 E0.04957 G1 X129.021 Y102.801 E0.01954 G1 X128.381 Y103.442 E0.03072 ;BEFORE_LAYER_CHANGE G92 E0.0 ;1 G1 F8640.000 G1 X129.021 Y102.801 E-0.20928 G1 X129.021 Y102.225 E-0.13311 G1 X127.987 Y103.259 E-0.33770 G1 X127.641 Y103.259 E-0.07992 G1 E-0.04000 F2100.00000 G1 Z1.400 F10800.000 ;AFTER_LAYER_CHANGE ;1 G1 X140.598 Y103.535 G1 Z1.000 G1 E0.80000 F2100.00000 M204 S800 G1 F1347 G1 X140.598 Y96.299 E0.24492 G1 X149.334 Y96.299 E0.29570 G1 X149.334 Y103.535 E0.24492 G1 X140.658 Y103.535 E0.29367 M204 S1000 G1 X140.191 Y103.942 F10800.000 M204 S800 G1 F1347 G1 X140.191 Y95.892 E0.27248 G1 X149.741 Y95.892 E0.32326 G1 X149.741 Y103.942 E0.27248 G1 X140.251 Y103.942 E0.32123 M204 S1000 G1 X140.305 Y103.559 F10800.000 G1 F8640.000 G1 X140.226 Y100.651 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z1.600 F10800.000 G1 X148.828 Y97.149 G1 Z1.000 G1 E0.80000 F2100.00000 G1 F1347 G1 X148.259 Y96.580 E0.02412 G1 X147.749 Y96.580 E0.01530 G1 X148.667 Y97.498 E0.03894 G1 X148.667 Y98.008 E0.01530 G1 X147.239 Y96.580 E0.06058 G1 X146.729 Y96.580 E0.01530 G1 X148.667 Y98.518 E0.08221 G1 X148.667 Y99.028 E0.01530 G1 X146.219 Y96.580 E0.10384 G1 X145.709 Y96.580 E0.01530 G1 X148.667 Y99.538 E0.12548 G1 X148.667 Y100.048 E0.01530 G1 X145.199 Y96.580 E0.14711 G1 X144.689 Y96.580 E0.01530 G1 X148.667 Y100.558 E0.16874 G1 X148.667 Y101.068 E0.01530 G1 X144.179 Y96.580 E0.19038 G1 X143.669 Y96.580 E0.01530 G1 X148.667 Y101.579 E0.21201 G1 X148.667 Y102.089 E0.01530 G1 X143.158 Y96.580 E0.23365 G1 X142.648 Y96.580 E0.01530 G1 X148.667 Y102.599 E0.25528 G1 X148.667 Y103.109 E0.01530 G1 X142.138 Y96.580 E0.27691 G1 X141.628 Y96.580 E0.01530 G1 X148.304 Y103.255 E0.28312 G1 X147.793 Y103.255 E0.01530 G1 X141.265 Y96.726 E0.27691 G1 X141.265 Y97.236 E0.01530 G1 X147.283 Y103.255 E0.25527 G1 X146.773 Y103.255 E0.01530 G1 X141.265 Y97.746 E0.23364 G1 X141.265 Y98.256 E0.01530 G1 X146.263 Y103.255 E0.21201 G1 X145.753 Y103.255 E0.01530 G1 X141.265 Y98.766 E0.19037 G1 X141.265 Y99.277 E0.01530 G1 X145.243 Y103.255 E0.16874 G1 X144.733 Y103.255 E0.01530 G1 X141.265 Y99.787 E0.14711 G1 X141.265 Y100.297 E0.01530 G1 X144.223 Y103.255 E0.12547 G1 X143.713 Y103.255 E0.01530 G1 X141.265 Y100.807 E0.10384 G1 X141.265 Y101.317 E0.01530 G1 X143.203 Y103.255 E0.08220 G1 X142.693 Y103.255 E0.01530 G1 X141.265 Y101.827 E0.06057 G1 X141.265 Y102.337 E0.01530 G1 X142.183 Y103.255 E0.03894 G1 X141.673 Y103.255 E0.01530 G1 X141.104 Y102.686 E0.02412 G1 F8640.000 G1 X141.673 Y103.255 E-0.18569 G1 X142.183 Y103.255 E-0.11778 G1 X141.265 Y102.337 E-0.29978 G1 X141.265 Y101.827 E-0.11778 G1 X141.384 Y101.946 E-0.03897 G1 E-0.04000 F2100.00000 G1 Z1.600 F10800.000 G1 X129.327 Y103.564 G1 Z1.000 G1 E0.80000 F2100.00000 M204 S800 G1 F1347 G1 X120.591 Y103.564 E0.29570 G1 X120.591 Y96.328 E0.24492 G1 X129.327 Y96.328 E0.29570 G1 X129.327 Y103.504 E0.24289 M73 Q9 S20 M204 S1000 G1 X129.734 Y103.971 F10800.000 M204 S800 G1 F1347 G1 X120.184 Y103.971 E0.32326 M73 P9 R20 G1 X120.184 Y95.921 E0.27248 G1 X129.734 Y95.921 E0.32326 G1 X129.734 Y103.911 E0.27045 M204 S1000 G1 X129.345 Y103.879 F10800.000 G1 F8640.000 G1 X126.442 Y103.932 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z1.600 F10800.000 G1 X121.097 Y102.715 G1 Z1.000 G1 E0.80000 F2100.00000 G1 F1347 G1 X121.665 Y103.284 E0.02412 G1 X122.176 Y103.284 E0.01530 G1 X121.257 Y102.366 E0.03894 G1 X121.257 Y101.856 E0.01530 G1 X122.686 Y103.284 E0.06057 G1 X123.196 Y103.284 E0.01530 G1 X121.257 Y101.345 E0.08220 G1 X121.257 Y100.835 E0.01530 G1 X123.706 Y103.284 E0.10384 G1 X124.216 Y103.284 E0.01530 G1 X121.257 Y100.325 E0.12547 G1 X121.257 Y99.815 E0.01530 G1 X124.726 Y103.284 E0.14711 G1 X125.236 Y103.284 E0.01530 G1 X121.257 Y99.305 E0.16874 G1 X121.257 Y98.795 E0.01530 G1 X125.746 Y103.284 E0.19037 G1 X126.256 Y103.284 E0.01530 G1 X121.257 Y98.285 E0.21201 G1 X121.257 Y97.775 E0.01530 G1 X126.766 Y103.284 E0.23364 G1 X127.276 Y103.284 E0.01530 G1 X121.257 Y97.265 E0.25527 G1 X121.257 Y96.755 E0.01530 G1 X127.786 Y103.284 E0.27691 G1 X128.296 Y103.284 E0.01530 G1 X121.621 Y96.608 E0.28312 G1 X122.131 Y96.608 E0.01530 G1 X128.660 Y103.137 E0.27691 G1 X128.660 Y102.627 E0.01530 G1 X122.641 Y96.608 E0.25528 G1 X123.151 Y96.608 E0.01530 G1 X128.660 Y102.117 E0.23365 G1 X128.660 Y101.607 E0.01530 G1 X123.661 Y96.608 E0.21201 G1 X124.172 Y96.608 E0.01530 G1 X128.660 Y101.097 E0.19038 G1 X128.660 Y100.587 E0.01530 G1 X124.682 Y96.608 E0.16874 G1 X125.192 Y96.608 E0.01530 G1 X128.660 Y100.077 E0.14711 G1 X128.660 Y99.567 E0.01530 G1 X125.702 Y96.608 E0.12548 G1 X126.212 Y96.608 E0.01530 G1 X128.660 Y99.057 E0.10384 G1 X128.660 Y98.547 E0.01530 G1 X126.722 Y96.608 E0.08221 G1 X127.232 Y96.608 E0.01530 G1 X128.660 Y98.037 E0.06058 G1 X128.660 Y97.527 E0.01530 G1 X127.742 Y96.608 E0.03894 G1 X128.252 Y96.608 E0.01530 G1 X128.821 Y97.177 E0.02412 ;BEFORE_LAYER_CHANGE G92 E0.0 ;1.2 G1 F8640.000 G1 X128.252 Y96.608 E-0.18574 G1 X127.742 Y96.608 E-0.11778 G1 X128.660 Y97.527 E-0.29983 G1 X128.660 Y98.037 E-0.11778 G1 X128.541 Y97.918 E-0.03888 G1 E-0.04000 F2100.00000 G1 Z1.600 F10800.000 ;AFTER_LAYER_CHANGE ;1.2 G1 X146.478 Y96.299 G1 Z1.200 G1 E0.80000 F2100.00000 M204 S800 G1 F1110 G1 X149.334 Y96.299 E0.09667 G1 X149.334 Y103.535 E0.24492 G1 X146.478 Y103.535 E0.09667 G1 X146.478 Y96.359 E0.24289 M204 S1000 G1 X146.071 Y95.892 F10800.000 M204 S800 G1 F1110 G1 X149.741 Y95.892 E0.12423 G1 X149.741 Y103.942 E0.27248 G1 X146.071 Y103.942 E0.12423 G1 X146.071 Y95.952 E0.27045 M204 S1000 G1 X146.442 Y96.041 F10800.000 G1 F8640.000 G1 X149.362 Y95.899 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z1.800 F10800.000 G1 X147.433 Y96.422 G1 Z1.200 G1 E0.80000 F2100.00000 G1 F1110 G1 X146.783 Y97.071 E0.03145 G1 X146.783 Y97.653 E0.01994 G1 X147.832 Y96.605 E0.05078 G1 X148.151 Y96.605 E0.01092 G1 X148.151 Y96.868 E0.00901 G1 X146.783 Y98.236 E0.06623 G1 X146.783 Y98.818 E0.01994 G1 X148.151 Y97.450 E0.06623 G1 X148.151 Y98.033 E0.01994 G1 X146.783 Y99.400 E0.06623 G1 X146.783 Y99.983 E0.01994 G1 X148.151 Y98.615 E0.06623 G1 X148.151 Y99.197 E0.01994 G1 X146.783 Y100.565 E0.06623 G1 X146.783 Y101.147 E0.01994 G1 X148.151 Y99.780 E0.06623 G1 X148.151 Y100.362 E0.01994 G1 X146.783 Y101.730 E0.06623 G1 X146.783 Y102.312 E0.01994 G1 X148.151 Y100.944 E0.06623 G1 X148.151 Y101.527 E0.01994 G1 X146.783 Y102.895 E0.06623 G1 X146.783 Y103.230 E0.01149 G1 X147.030 Y103.230 E0.00845 G1 X148.151 Y102.109 E0.05428 G1 X148.151 Y102.691 E0.01994 G1 X147.429 Y103.413 E0.03495 G1 X148.375 Y103.370 F10800.000 G1 F1110 G1 X149.029 Y102.716 E0.03129 G1 X149.029 Y102.102 E0.02078 G1 X148.558 Y102.572 E0.02252 G1 X148.558 Y101.958 E0.02078 G1 X149.029 Y101.488 E0.02252 G1 X149.029 Y100.874 E0.02078 G1 X148.558 Y101.344 E0.02252 G1 X148.558 Y100.731 E0.02078 G1 X149.029 Y100.260 E0.02252 G1 X149.029 Y99.646 E0.02078 G1 X148.558 Y100.117 E0.02252 G1 X148.558 Y99.503 E0.02078 G1 X149.029 Y99.032 E0.02252 G1 X149.029 Y98.418 E0.02078 G1 X148.558 Y98.889 E0.02252 G1 X148.558 Y98.275 E0.02078 G1 X149.029 Y97.804 E0.02252 G1 X149.029 Y97.190 E0.02078 G1 X148.558 Y97.661 E0.02252 G1 X148.558 Y97.047 E0.02078 G1 X149.183 Y96.422 E0.02992 G1 F8640.000 G1 X148.558 Y97.047 E-0.20408 G1 X148.558 Y97.661 E-0.14177 G1 X149.029 Y97.190 E-0.15363 G1 X149.029 Y97.804 E-0.14177 G1 X148.665 Y98.168 E-0.11875 G1 E-0.04000 F2100.00000 G1 Z1.800 F10800.000 G1 X143.454 Y96.422 G1 Z1.200 G1 E0.80000 F2100.00000 M204 S800 G1 F1110 G1 X143.454 Y103.535 E0.24079 G1 X140.598 Y103.535 E0.09667 G1 X140.598 Y96.299 E0.24492 G1 X143.454 Y96.299 E0.09667 G1 X143.454 Y96.362 E0.00210 M204 S1000 G1 X143.861 Y95.892 F10800.000 M204 S800 G1 F1110 G1 X143.861 Y103.942 E0.27248 G1 X140.191 Y103.942 E0.12423 G1 X140.191 Y95.892 E0.27248 G1 X143.801 Y95.892 E0.12220 M204 S1000 G1 X143.804 Y96.288 F10800.000 G1 F8640.000 G1 X143.826 Y99.184 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z1.800 F10800.000 G1 X142.503 Y96.422 G1 Z1.200 G1 E0.80000 F2100.00000 G1 F1110 G1 X141.781 Y97.143 E0.03494 G1 X141.781 Y97.726 E0.01994 G1 X142.902 Y96.605 E0.05427 G1 X143.149 Y96.605 E0.00846 G1 X143.149 Y96.940 E0.01148 G1 X141.781 Y98.308 E0.06623 G1 X141.781 Y98.890 E0.01994 G1 X143.149 Y97.522 E0.06623 G1 X143.149 Y98.105 E0.01994 G1 X141.781 Y99.473 E0.06623 G1 X141.781 Y100.055 E0.01994 G1 X143.149 Y98.687 E0.06623 G1 X143.149 Y99.269 E0.01994 G1 X141.781 Y100.637 E0.06623 G1 X141.781 Y101.220 E0.01994 G1 X143.149 Y99.852 E0.06623 G1 X143.149 Y100.434 E0.01994 G1 X141.781 Y101.802 E0.06623 G1 X141.781 Y102.384 E0.01994 G1 X143.149 Y101.016 E0.06623 G1 X143.149 Y101.599 E0.01994 G1 X141.781 Y102.967 E0.06623 G1 X141.781 Y103.230 E0.00902 G1 X142.100 Y103.230 E0.01092 G1 X143.149 Y102.181 E0.05079 G1 X143.149 Y102.763 E0.01994 G1 X142.499 Y103.413 E0.03146 G1 F8640.000 G1 X143.149 Y102.763 E-0.21215 G1 X143.149 Y102.181 E-0.13446 G1 X142.100 Y103.230 E-0.34249 G1 X141.793 Y103.230 E-0.07089 G1 E-0.04000 F2100.00000 G1 Z1.800 F10800.000 G1 X140.749 Y103.413 G1 Z1.200 G1 E0.80000 F2100.00000 G1 F1110 G1 X141.374 Y102.788 E0.02992 G1 X141.374 Y102.174 E0.02078 G1 X140.903 Y102.645 E0.02252 G1 X140.903 Y102.031 E0.02078 G1 X141.374 Y101.560 E0.02252 G1 X141.374 Y100.946 E0.02078 G1 X140.903 Y101.417 E0.02252 G1 X140.903 Y100.803 E0.02078 G1 X141.374 Y100.332 E0.02252 G1 X141.374 Y99.718 E0.02078 G1 X140.903 Y100.189 E0.02252 G1 X140.903 Y99.575 E0.02078 G1 X141.374 Y99.104 E0.02252 G1 X141.374 Y98.490 E0.02078 G1 X140.903 Y98.961 E0.02252 G1 X140.903 Y98.347 E0.02078 G1 X141.374 Y97.876 E0.02252 G1 X141.374 Y97.262 E0.02078 G1 X140.903 Y97.733 E0.02252 G1 X140.903 Y97.119 E0.02078 G1 X141.557 Y96.465 E0.03129 G1 F8640.000 G1 X140.903 Y97.119 E-0.21344 G1 X140.903 Y97.733 E-0.14177 G1 X141.374 Y97.262 E-0.15363 G1 X141.374 Y97.876 E-0.14177 G1 X141.039 Y98.211 E-0.10939 G1 E-0.04000 F2100.00000 G1 Z1.800 F10800.000 G1 X129.327 Y96.465 G1 Z1.200 G1 E0.80000 F2100.00000 M204 S800 G1 F1110 G1 X129.327 Y103.564 E0.24029 G1 X126.471 Y103.564 E0.09667 G1 X126.471 Y96.328 E0.24492 G1 X129.327 Y96.328 E0.09667 G1 X129.327 Y96.405 E0.00260 M204 S1000 G1 X129.734 Y95.921 F10800.000 M204 S800 G1 F1110 G1 X129.734 Y103.971 E0.27248 G1 X126.064 Y103.971 E0.12423 G1 X126.064 Y95.921 E0.27248 G1 X129.674 Y95.921 E0.12220 M204 S1000 G1 X129.677 Y96.317 F10800.000 G1 X129.176 Y96.450 G1 F1110 G1 X128.551 Y97.075 E0.02992 G1 X128.551 Y97.689 E0.02078 G1 X129.021 Y97.219 E0.02252 G1 X129.021 Y97.833 E0.02078 G1 X128.551 Y98.303 E0.02252 G1 X128.551 Y98.917 E0.02078 G1 X129.021 Y98.447 E0.02252 G1 X129.021 Y99.061 E0.02078 G1 X128.551 Y99.531 E0.02252 G1 X128.551 Y100.145 E0.02078 G1 X129.021 Y99.675 E0.02252 G1 X129.021 Y100.289 E0.02078 G1 X128.551 Y100.759 E0.02252 G1 X128.551 Y101.373 E0.02078 G1 X129.021 Y100.903 E0.02252 G1 X129.021 Y101.517 E0.02078 G1 X128.551 Y101.987 E0.02252 G1 X128.551 Y102.601 E0.02078 G1 X129.021 Y102.131 E0.02252 G1 X129.021 Y102.745 E0.02078 G1 X128.368 Y103.398 E0.03129 G1 X127.422 Y103.442 F10800.000 G1 F1110 G1 X128.144 Y102.720 E0.03495 G1 X128.144 Y102.138 E0.01994 G1 X127.023 Y103.259 E0.05428 G1 X126.776 Y103.259 E0.00845 G1 X126.776 Y102.923 E0.01149 G1 X128.144 Y101.555 E0.06623 G1 X128.144 Y100.973 E0.01994 G1 X126.776 Y102.341 E0.06623 G1 X126.776 Y101.758 E0.01994 G1 X128.144 Y100.391 E0.06623 G1 X128.144 Y99.808 E0.01994 G1 X126.776 Y101.176 E0.06623 G1 X126.776 Y100.594 E0.01994 G1 X128.144 Y99.226 E0.06623 G1 X128.144 Y98.644 E0.01994 G1 X126.776 Y100.011 E0.06623 G1 X126.776 Y99.429 E0.01994 G1 X128.144 Y98.061 E0.06623 G1 X128.144 Y97.479 E0.01994 G1 X126.776 Y98.847 E0.06623 G1 X126.776 Y98.264 E0.01994 G1 X128.144 Y96.897 E0.06623 G1 X128.144 Y96.633 E0.00901 G1 X127.825 Y96.633 E0.01092 G1 X126.776 Y97.682 E0.05078 G1 X126.776 Y97.100 E0.01994 G1 X127.426 Y96.450 E0.03145 G1 F8640.000 G1 X126.776 Y97.100 E-0.21211 G1 X126.776 Y97.682 E-0.13446 G1 X127.825 Y96.633 E-0.34245 G1 X128.132 Y96.633 E-0.07098 G1 E-0.04000 F2100.00000 G1 Z1.800 F10800.000 G1 X123.447 Y96.450 G1 Z1.200 G1 E0.80000 F2100.00000 M204 S800 G1 F1110 G1 X123.447 Y103.564 E0.24079 G1 X120.591 Y103.564 E0.09667 G1 X120.591 Y96.328 E0.24492 G1 X123.447 Y96.328 E0.09667 G1 X123.447 Y96.390 E0.00210 M204 S1000 G1 X123.854 Y95.921 F10800.000 M204 S800 G1 F1110 G1 X123.854 Y103.971 E0.27248 G1 X120.184 Y103.971 E0.12423 G1 X120.184 Y95.921 E0.27248 G1 X123.794 Y95.921 E0.12220 M204 S1000 G1 X123.797 Y96.317 F10800.000 G1 F8640.000 G1 X123.818 Y99.212 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z1.800 F10800.000 G1 X122.495 Y96.450 G1 Z1.200 G1 E0.80000 F2100.00000 G1 F1110 G1 X121.774 Y97.172 E0.03494 G1 X121.774 Y97.754 E0.01994 G1 X122.895 Y96.633 E0.05427 G1 X123.142 Y96.633 E0.00846 G1 X123.142 Y96.969 E0.01148 G1 X121.774 Y98.337 E0.06623 G1 X121.774 Y98.919 E0.01994 G1 X123.142 Y97.551 E0.06623 G1 X123.142 Y98.133 E0.01994 G1 X121.774 Y99.501 E0.06623 G1 X121.774 Y100.084 E0.01994 G1 X123.142 Y98.716 E0.06623 G1 X123.142 Y99.298 E0.01994 G1 X121.774 Y100.666 E0.06623 G1 X121.774 Y101.248 E0.01994 G1 X123.142 Y99.880 E0.06623 G1 X123.142 Y100.463 E0.01994 G1 X121.774 Y101.831 E0.06623 G1 X121.774 Y102.413 E0.01994 G1 X123.142 Y101.045 E0.06623 G1 X123.142 Y101.627 E0.01994 G1 X121.774 Y102.995 E0.06623 G1 X121.774 Y103.259 E0.00902 G1 X122.093 Y103.259 E0.01092 G1 X123.142 Y102.210 E0.05079 G1 X123.142 Y102.792 E0.01994 G1 X122.492 Y103.442 E0.03146 G1 F8640.000 G1 X123.142 Y102.792 E-0.21215 G1 X123.142 Y102.210 E-0.13446 G1 X122.093 Y103.259 E-0.34249 G1 X121.786 Y103.259 E-0.07089 G1 E-0.04000 F2100.00000 G1 Z1.800 F10800.000 G1 X120.742 Y103.442 G1 Z1.200 G1 E0.80000 F2100.00000 G1 F1110 G1 X121.367 Y102.817 E0.02992 G1 X121.367 Y102.203 E0.02078 G1 X120.896 Y102.673 E0.02252 G1 X120.896 Y102.059 E0.02078 G1 X121.367 Y101.589 E0.02252 G1 X121.367 Y100.975 E0.02078 G1 X120.896 Y101.445 E0.02252 G1 X120.896 Y100.831 E0.02078 G1 X121.367 Y100.361 E0.02252 G1 X121.367 Y99.747 E0.02078 G1 X120.896 Y100.217 E0.02252 G1 X120.896 Y99.603 E0.02078 G1 X121.367 Y99.133 E0.02252 G1 X121.367 Y98.519 E0.02078 G1 X120.896 Y98.989 E0.02252 G1 X120.896 Y98.375 E0.02078 G1 X121.367 Y97.905 E0.02252 G1 X121.367 Y97.291 E0.02078 G1 X120.896 Y97.761 E0.02252 G1 X120.896 Y97.147 E0.02078 G1 X121.550 Y96.494 E0.03129 ;BEFORE_LAYER_CHANGE G92 E0.0 ;1.4 G1 F8640.000 G1 X120.896 Y97.147 E-0.21344 G1 X120.896 Y97.761 E-0.14177 G1 X121.367 Y97.291 E-0.15363 G1 X121.367 Y97.905 E-0.14177 G1 X121.032 Y98.240 E-0.10938 G1 E-0.04000 F2100.00000 G1 Z1.800 F10800.000 ;AFTER_LAYER_CHANGE ;1.4 G1 X147.115 Y96.299 G1 Z1.400 G1 E0.80000 F2100.00000 M204 S800 G1 F949 G1 X149.334 Y96.299 E0.07512 G1 X149.334 Y103.535 E0.24492 G1 X147.115 Y103.535 E0.07512 G1 X147.115 Y96.359 E0.24289 M204 S1000 G1 X146.708 Y95.892 F10800.000 M204 S800 G1 F949 G1 X149.741 Y95.892 E0.10267 G1 X149.741 Y103.942 E0.27248 G1 X146.708 Y103.942 E0.10267 G1 X146.708 Y95.952 E0.27045 M204 S1000 G1 X147.076 Y96.049 F10800.000 G1 F8640.000 G1 X149.741 Y95.892 E-0.70054 G1 X149.741 Y96.150 E-0.05946 G1 E-0.04000 F2100.00000 G1 Z2.000 F10800.000 G1 X148.562 Y97.345 G1 Z1.400 G1 E0.80000 F2100.00000 G1 F949 G1 X147.821 Y96.605 E0.03661 G1 X147.420 Y96.605 E0.01404 G1 X147.420 Y96.798 E0.00676 G1 X148.379 Y97.757 E0.04740 G1 X148.379 Y98.351 E0.02079 G1 X147.420 Y97.393 E0.04740 G1 X147.420 Y97.987 E0.02079 G1 X148.379 Y98.946 E0.04740 G1 X148.379 Y99.541 E0.02079 G1 X147.420 Y98.582 E0.04740 G1 X147.420 Y99.177 E0.02079 G1 X148.379 Y100.135 E0.04740 G1 X148.379 Y100.730 E0.02079 G1 X147.420 Y99.772 E0.04740 G1 X147.420 Y100.366 E0.02079 G1 X148.379 Y101.325 E0.04740 G1 X148.379 Y101.920 E0.02079 G1 X147.420 Y100.961 E0.04740 G1 X147.420 Y101.556 E0.02079 G1 X148.379 Y102.514 E0.04740 G1 X148.379 Y103.109 E0.02079 G1 X147.420 Y102.150 E0.04740 G1 X147.420 Y102.745 E0.02079 G1 X148.088 Y103.413 E0.03304 G1 X148.602 Y102.631 F10800.000 G1 F949 G1 X149.029 Y103.057 E0.02040 G1 X149.029 Y102.461 E0.02019 G1 X148.786 Y102.218 E0.01163 G1 X148.786 Y101.621 E0.02019 G1 X149.029 Y101.864 E0.01163 G1 X149.029 Y101.268 E0.02019 G1 X148.786 Y101.025 E0.01163 G1 X148.786 Y100.429 E0.02019 G1 X149.029 Y100.671 E0.01163 G1 X149.029 Y100.075 E0.02019 G1 X148.786 Y99.832 E0.01163 G1 X148.786 Y99.236 E0.02019 G1 X149.029 Y99.478 E0.01163 G1 X149.029 Y98.882 E0.02019 G1 X148.786 Y98.639 E0.01163 G1 X148.786 Y98.043 E0.02019 G1 X149.029 Y98.285 E0.01163 G1 X149.029 Y97.689 E0.02019 G1 X148.786 Y97.446 E0.01163 G1 X148.786 Y96.850 E0.02019 G1 X149.212 Y97.276 E0.02040 G1 F8640.000 G1 X148.786 Y96.850 E-0.13915 G1 X148.786 Y97.446 E-0.13773 G1 X149.029 Y97.689 E-0.07933 G1 X149.029 Y98.285 E-0.13773 G1 X148.786 Y98.043 E-0.07933 G1 X148.786 Y98.639 E-0.13773 G1 X148.936 Y98.789 E-0.04899 G1 E-0.04000 F2100.00000 G1 Z2.000 F10800.000 G1 X142.817 Y96.299 G1 Z1.400 G1 E0.80000 F2100.00000 M204 S800 G1 F949 G1 X142.817 Y103.535 E0.24492 G1 X140.598 Y103.535 E0.07512 G1 X140.598 Y96.299 E0.24492 G1 X142.757 Y96.299 E0.07309 M204 S1000 G1 X143.224 Y95.892 F10800.000 M204 S800 G1 F949 G1 X143.224 Y103.942 E0.27248 G1 X140.191 Y103.942 E0.10267 G1 X140.191 Y95.892 E0.27248 G1 X143.164 Y95.892 E0.10064 M204 S1000 G1 X143.176 Y96.290 F10800.000 G1 F8640.000 G1 X143.189 Y99.184 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z2.000 F10800.000 G1 X142.695 Y97.273 G1 Z1.400 G1 E0.80000 F2100.00000 G1 F949 G1 X142.027 Y96.605 E0.03304 G1 X141.553 Y96.605 E0.01656 G1 X141.553 Y96.726 E0.00424 G1 X142.512 Y97.685 E0.04740 G1 X142.512 Y98.279 E0.02079 G1 X141.553 Y97.321 E0.04740 G1 X141.553 Y97.915 E0.02079 G1 X142.512 Y98.874 E0.04740 G1 X142.512 Y99.469 E0.02079 G1 X141.553 Y98.510 E0.04740 G1 X141.553 Y99.105 E0.02079 G1 X142.512 Y100.063 E0.04740 G1 X142.512 Y100.658 E0.02079 G1 X141.553 Y99.699 E0.04740 G1 X141.553 Y100.294 E0.02079 G1 X142.512 Y101.253 E0.04740 G1 X142.512 Y101.847 E0.02079 G1 X141.553 Y100.889 E0.04740 G1 X141.553 Y101.484 E0.02079 G1 X142.512 Y102.442 E0.04740 G1 X142.512 Y103.037 E0.02079 G1 X141.553 Y102.078 E0.04740 G1 X141.553 Y102.673 E0.02079 G1 X142.294 Y103.413 E0.03660 G1 F8640.000 G1 X141.553 Y102.673 E-0.24170 G1 X141.553 Y102.078 E-0.13732 G1 X142.512 Y103.037 E-0.31301 G1 X142.512 Y102.742 E-0.06797 G1 E-0.04000 F2100.00000 G1 Z2.000 F10800.000 G1 X140.720 Y102.559 G1 Z1.400 G1 E0.80000 F2100.00000 G1 F949 G1 X141.146 Y102.985 E0.02040 G1 X141.146 Y102.389 E0.02019 G1 X140.903 Y102.146 E0.01163 G1 X140.903 Y101.549 E0.02019 G1 X141.146 Y101.792 E0.01163 G1 X141.146 Y101.196 E0.02019 G1 X140.903 Y100.953 E0.01163 G1 X140.903 Y100.356 E0.02019 G1 X141.146 Y100.599 E0.01163 G1 X141.146 Y100.003 E0.02019 G1 X140.903 Y99.760 E0.01163 G1 X140.903 Y99.163 E0.02019 G1 X141.146 Y99.406 E0.01163 G1 X141.146 Y98.810 E0.02019 G1 X140.903 Y98.567 E0.01163 G1 X140.903 Y97.970 E0.02019 G1 X141.146 Y98.213 E0.01163 G1 X141.146 Y97.617 E0.02019 G1 X140.903 Y97.374 E0.01163 G1 X140.903 Y96.777 E0.02019 G1 X141.329 Y97.204 E0.02040 G1 F8640.000 G1 X140.903 Y96.777 E-0.13915 G1 X140.903 Y97.374 E-0.13773 G1 X141.146 Y97.617 E-0.07933 G1 X141.146 Y98.213 E-0.13773 G1 X140.903 Y97.970 E-0.07933 G1 X140.903 Y98.567 E-0.13773 G1 X141.053 Y98.717 E-0.04899 G1 E-0.04000 F2100.00000 G1 Z2.000 F10800.000 G1 X129.327 Y96.328 G1 Z1.400 G1 E0.80000 F2100.00000 M204 S800 G1 F949 G1 X129.327 Y103.564 E0.24492 G1 X127.108 Y103.564 E0.07512 G1 X127.108 Y96.328 E0.24492 G1 X129.267 Y96.328 E0.07309 M204 S1000 G1 X129.734 Y95.921 F10800.000 M204 S800 G1 F949 G1 X129.734 Y103.971 E0.27248 G1 X126.701 Y103.971 E0.10267 G1 X126.701 Y95.921 E0.27248 G1 X129.674 Y95.921 E0.10064 M204 S1000 G1 X129.686 Y96.318 F10800.000 G1 F8640.000 G1 X129.698 Y99.212 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z2.000 F10800.000 G1 X129.205 Y97.304 G1 Z1.400 G1 E0.80000 F2100.00000 G1 F949 G1 X128.779 Y96.878 E0.02040 G1 X128.779 Y97.475 E0.02019 G1 X129.021 Y97.718 E0.01163 G1 X129.021 Y98.314 E0.02019 G1 X128.779 Y98.071 E0.01163 G1 X128.779 Y98.668 E0.02019 G1 X129.021 Y98.911 E0.01163 G1 X129.021 Y99.507 E0.02019 G1 X128.779 Y99.264 E0.01163 G1 X128.779 Y99.861 E0.02019 G1 X129.021 Y100.104 E0.01163 G1 X129.021 Y100.700 E0.02019 G1 X128.779 Y100.457 E0.01163 G1 X128.779 Y101.054 E0.02019 G1 X129.021 Y101.297 E0.01163 G1 X129.021 Y101.893 E0.02019 G1 X128.779 Y101.650 E0.01163 G1 X128.779 Y102.247 E0.02019 G1 X129.021 Y102.490 E0.01163 G1 X129.021 Y103.086 E0.02019 G1 X128.595 Y102.660 E0.02040 G1 X128.081 Y103.442 F10800.000 G1 F949 G1 X127.413 Y102.774 E0.03304 G1 X127.413 Y102.179 E0.02079 G1 X128.371 Y103.138 E0.04740 G1 X128.371 Y102.543 E0.02079 G1 X127.413 Y101.584 E0.04740 G1 X127.413 Y100.990 E0.02079 G1 X128.371 Y101.948 E0.04740 G1 X128.371 Y101.353 E0.02079 G1 X127.413 Y100.395 E0.04740 G1 X127.413 Y99.800 E0.02079 G1 X128.371 Y100.759 E0.04740 G1 X128.371 Y100.164 E0.02079 G1 X127.413 Y99.206 E0.04740 G1 X127.413 Y98.611 E0.02079 G1 X128.371 Y99.569 E0.04740 G1 X128.371 Y98.975 E0.02079 G1 X127.413 Y98.016 E0.04740 G1 X127.413 Y97.421 E0.02079 G1 X128.371 Y98.380 E0.04740 G1 X128.371 Y97.785 E0.02079 G1 X127.413 Y96.827 E0.04740 G1 X127.413 Y96.633 E0.00676 G1 X127.814 Y96.633 E0.01404 G1 X128.555 Y97.374 E0.03661 G1 F8640.000 G1 X127.814 Y96.633 E-0.24175 G1 X127.413 Y96.633 E-0.09269 G1 X127.413 Y96.827 E-0.04463 G1 X128.371 Y97.785 E-0.31301 G1 X128.371 Y98.079 E-0.06792 G1 E-0.04000 F2100.00000 G1 Z2.000 F10800.000 G1 X122.810 Y96.328 G1 Z1.400 G1 E0.80000 F2100.00000 M204 S800 G1 F949 G1 X122.810 Y103.564 E0.24492 G1 X120.591 Y103.564 E0.07512 G1 X120.591 Y96.328 E0.24492 G1 X122.750 Y96.328 E0.07309 M204 S1000 G1 X123.217 Y95.921 F10800.000 M204 S800 G1 F949 G1 X123.217 Y103.971 E0.27248 G1 X120.184 Y103.971 E0.10267 G1 X120.184 Y95.921 E0.27248 G1 X123.157 Y95.921 E0.10064 M204 S1000 G1 X123.169 Y96.318 F10800.000 G1 F8640.000 G1 X123.182 Y99.212 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z2.000 F10800.000 G1 X122.688 Y97.302 G1 Z1.400 G1 E0.80000 F2100.00000 G1 F949 G1 X122.020 Y96.633 E0.03304 G1 X121.546 Y96.633 E0.01656 G1 X121.546 Y96.755 E0.00424 G1 X122.505 Y97.713 E0.04740 G1 X122.505 Y98.308 E0.02079 G1 X121.546 Y97.349 E0.04740 G1 X121.546 Y97.944 E0.02079 G1 X122.505 Y98.903 E0.04740 G1 X122.505 Y99.497 E0.02079 G1 X121.546 Y98.539 E0.04740 G1 X121.546 Y99.133 E0.02079 G1 X122.505 Y100.092 E0.04740 G1 X122.505 Y100.687 E0.02079 G1 X121.546 Y99.728 E0.04740 G1 X121.546 Y100.323 E0.02079 G1 X122.505 Y101.281 E0.04740 G1 X122.505 Y101.876 E0.02079 G1 X121.546 Y100.918 E0.04740 G1 X121.546 Y101.512 E0.02079 G1 X122.505 Y102.471 E0.04740 G1 X122.505 Y103.066 E0.02079 G1 X121.546 Y102.107 E0.04740 G1 X121.546 Y102.702 E0.02079 G1 X122.286 Y103.442 E0.03660 G1 F8640.000 G1 X121.546 Y102.702 E-0.24170 G1 X121.546 Y102.107 E-0.13732 G1 X122.505 Y103.066 E-0.31301 G1 X122.505 Y102.771 E-0.06797 G1 E-0.04000 F2100.00000 G1 Z2.000 F10800.000 G1 X120.713 Y102.588 G1 Z1.400 G1 E0.80000 F2100.00000 G1 F949 G1 X121.139 Y103.014 E0.02040 G1 X121.139 Y102.418 E0.02019 G1 X120.896 Y102.175 E0.01163 G1 X120.896 Y101.578 E0.02019 G1 X121.139 Y101.821 E0.01163 G1 X121.139 Y101.225 E0.02019 G1 X120.896 Y100.982 E0.01163 G1 X120.896 Y100.385 E0.02019 G1 X121.139 Y100.628 E0.01163 G1 X121.139 Y100.032 E0.02019 G1 X120.896 Y99.789 E0.01163 G1 X120.896 Y99.192 E0.02019 G1 X121.139 Y99.435 E0.01163 G1 X121.139 Y98.839 E0.02019 G1 X120.896 Y98.596 E0.01163 G1 X120.896 Y97.999 E0.02019 G1 X121.139 Y98.242 E0.01163 G1 X121.139 Y97.646 E0.02019 G1 X120.896 Y97.403 E0.01163 G1 X120.896 Y96.806 E0.02019 G1 X121.322 Y97.232 E0.02040 ;BEFORE_LAYER_CHANGE G92 E0.0 ;1.6 G1 F8640.000 G1 X120.896 Y96.806 E-0.13915 G1 X120.896 Y97.403 E-0.13773 G1 X121.139 Y97.646 E-0.07933 G1 X121.139 Y98.242 E-0.13773 G1 X120.896 Y97.999 E-0.07933 G1 X120.896 Y98.596 E-0.13773 G1 X121.046 Y98.746 E-0.04899 G1 E-0.04000 F2100.00000 G1 Z2.000 F10800.000 ;AFTER_LAYER_CHANGE ;1.6 G1 X147.534 Y96.299 G1 Z1.600 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X149.334 Y96.299 E0.06093 G1 X149.334 Y103.535 E0.24492 G1 X147.534 Y103.535 E0.06093 G1 X147.534 Y96.359 E0.24289 M204 S1000 G1 X147.127 Y95.892 F10800.000 M204 S800 G1 F900 G1 X149.741 Y95.892 E0.08849 G1 X149.741 Y103.942 E0.27248 M73 Q13 S19 G1 X147.127 Y103.942 E0.08849 G1 X147.127 Y95.952 E0.27045 M73 P13 R19 M204 S1000 G1 X147.492 Y96.055 F10800.000 G1 F8640.000 G1 X149.741 Y95.892 E-0.60377 G1 X149.741 Y96.569 E-0.15623 G1 E-0.04000 F2100.00000 G1 Z2.200 F10800.000 G1 X148.328 Y103.413 G1 Z1.600 G1 E0.80000 F2100.00000 G1 F900 G1 X149.029 Y102.712 E0.03591 G1 X149.029 Y102.096 E0.02234 G1 X147.895 Y103.230 E0.05811 G1 X147.839 Y103.230 E0.00201 G1 X147.839 Y102.669 E0.02032 G1 X149.029 Y101.480 E0.06096 G1 X149.029 Y100.863 E0.02234 G1 X147.839 Y102.053 E0.06096 G1 X147.839 Y101.437 E0.02234 G1 X149.029 Y100.247 E0.06096 G1 X149.029 Y99.631 E0.02234 G1 X147.839 Y100.820 E0.06096 G1 X147.839 Y100.204 E0.02234 G1 X149.029 Y99.014 E0.06096 G1 X149.029 Y98.398 E0.02234 G1 X147.839 Y99.588 E0.06096 G1 X147.839 Y98.971 E0.02234 G1 X149.029 Y97.782 E0.06096 G1 X149.029 Y97.165 E0.02234 G1 X147.839 Y98.355 E0.06096 G1 X147.839 Y97.738 E0.02234 G1 X148.973 Y96.605 E0.05810 G1 X148.357 Y96.605 E0.02234 G1 X147.656 Y97.305 E0.03590 G1 F8640.000 G1 X148.357 Y96.605 E-0.22877 G1 X148.973 Y96.605 E-0.14232 G1 X147.839 Y97.738 E-0.37021 G1 X147.839 Y97.819 E-0.01871 G1 E-0.04000 F2100.00000 G1 Z2.200 F10800.000 G1 X142.398 Y96.299 G1 Z1.600 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X142.398 Y103.535 E0.24492 G1 X140.598 Y103.535 E0.06093 G1 X140.598 Y96.299 E0.24492 G1 X142.338 Y96.299 E0.05890 M204 S1000 G1 X142.805 Y95.892 F10800.000 M204 S800 G1 F900 G1 X142.805 Y103.942 E0.27248 G1 X140.191 Y103.942 E0.08849 G1 X140.191 Y95.892 E0.27248 G1 X142.745 Y95.892 E0.08645 M204 S1000 G1 X142.763 Y96.290 F10800.000 G1 F8640.000 G1 X142.770 Y99.184 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z2.200 F10800.000 G1 X141.392 Y103.413 G1 Z1.600 G1 E0.80000 F2100.00000 G1 F900 G1 X142.093 Y102.712 E0.03591 G1 X142.093 Y102.096 E0.02234 G1 X140.959 Y103.230 E0.05811 G1 X140.903 Y103.230 E0.00201 G1 X140.903 Y102.669 E0.02032 G1 X142.093 Y101.480 E0.06095 G1 X142.093 Y100.863 E0.02234 G1 X140.903 Y102.053 E0.06095 G1 X140.903 Y101.437 E0.02234 G1 X142.093 Y100.247 E0.06095 G1 X142.093 Y99.631 E0.02234 G1 X140.903 Y100.820 E0.06095 G1 X140.903 Y100.204 E0.02234 G1 X142.093 Y99.014 E0.06095 G1 X142.093 Y98.398 E0.02234 G1 X140.903 Y99.587 E0.06095 G1 X140.903 Y98.971 E0.02234 G1 X142.093 Y97.782 E0.06095 G1 X142.093 Y97.165 E0.02234 G1 X140.903 Y98.355 E0.06095 G1 X140.903 Y97.738 E0.02234 G1 X142.037 Y96.605 E0.05810 G1 X141.421 Y96.605 E0.02234 G1 X140.720 Y97.305 E0.03590 G1 F8640.000 G1 X141.421 Y96.605 E-0.22876 G1 X142.037 Y96.605 E-0.14232 G1 X140.903 Y97.738 E-0.37021 G1 X140.903 Y97.820 E-0.01871 G1 E-0.04000 F2100.00000 G1 Z2.200 F10800.000 G1 X129.327 Y96.328 G1 Z1.600 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X129.327 Y103.564 E0.24492 G1 X127.527 Y103.564 E0.06093 G1 X127.527 Y96.328 E0.24492 G1 X129.267 Y96.328 E0.05890 M204 S1000 G1 X129.734 Y95.921 F10800.000 M204 S800 G1 F900 G1 X129.734 Y103.971 E0.27248 G1 X127.120 Y103.971 E0.08849 G1 X127.120 Y95.921 E0.27248 G1 X129.674 Y95.921 E0.08645 M204 S1000 G1 X129.692 Y96.319 F10800.000 G1 F8640.000 G1 X129.698 Y99.212 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z2.200 F10800.000 G1 X128.321 Y103.442 G1 Z1.600 G1 E0.80000 F2100.00000 G1 F900 G1 X129.021 Y102.741 E0.03591 G1 X129.021 Y102.125 E0.02234 G1 X127.888 Y103.259 E0.05811 G1 X127.832 Y103.259 E0.00201 G1 X127.832 Y102.698 E0.02032 G1 X129.021 Y101.508 E0.06096 G1 X129.021 Y100.892 E0.02234 G1 X127.832 Y102.082 E0.06096 G1 X127.832 Y101.465 E0.02234 G1 X129.021 Y100.276 E0.06096 G1 X129.021 Y99.659 E0.02234 G1 X127.832 Y100.849 E0.06096 G1 X127.832 Y100.233 E0.02234 G1 X129.021 Y99.043 E0.06096 G1 X129.021 Y98.427 E0.02234 G1 X127.832 Y99.616 E0.06096 G1 X127.832 Y99.000 E0.02234 G1 X129.021 Y97.810 E0.06096 G1 X129.021 Y97.194 E0.02234 G1 X127.832 Y98.383 E0.06096 G1 X127.832 Y97.767 E0.02234 G1 X128.966 Y96.633 E0.05810 G1 X128.349 Y96.633 E0.02234 G1 X127.649 Y97.334 E0.03590 G1 F8640.000 G1 X128.349 Y96.633 E-0.22877 G1 X128.966 Y96.633 E-0.14232 G1 X127.832 Y97.767 E-0.37021 G1 X127.832 Y97.848 E-0.01871 G1 E-0.04000 F2100.00000 G1 Z2.200 F10800.000 G1 X122.391 Y96.328 G1 Z1.600 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X122.391 Y103.564 E0.24492 G1 X120.591 Y103.564 E0.06093 G1 X120.591 Y96.328 E0.24492 G1 X122.331 Y96.328 E0.05890 M204 S1000 G1 X122.798 Y95.921 F10800.000 M204 S800 G1 F900 G1 X122.798 Y103.971 E0.27248 G1 X120.184 Y103.971 E0.08849 G1 X120.184 Y95.921 E0.27248 G1 X122.738 Y95.921 E0.08645 M204 S1000 G1 X122.756 Y96.319 F10800.000 G1 F8640.000 G1 X122.763 Y99.212 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z2.200 F10800.000 G1 X121.385 Y103.442 G1 Z1.600 G1 E0.80000 F2100.00000 G1 F900 G1 X122.086 Y102.741 E0.03591 G1 X122.086 Y102.125 E0.02234 G1 X120.952 Y103.259 E0.05811 G1 X120.896 Y103.259 E0.00201 G1 X120.896 Y102.698 E0.02032 G1 X122.086 Y101.508 E0.06095 G1 X122.086 Y100.892 E0.02234 G1 X120.896 Y102.082 E0.06095 G1 X120.896 Y101.465 E0.02234 G1 X122.086 Y100.276 E0.06095 G1 X122.086 Y99.659 E0.02234 G1 X120.896 Y100.849 E0.06095 G1 X120.896 Y100.233 E0.02234 G1 X122.086 Y99.043 E0.06095 G1 X122.086 Y98.427 E0.02234 G1 X120.896 Y99.616 E0.06095 G1 X120.896 Y99.000 E0.02234 G1 X122.086 Y97.810 E0.06095 G1 X122.086 Y97.194 E0.02234 G1 X120.896 Y98.383 E0.06095 G1 X120.896 Y97.767 E0.02234 G1 X122.030 Y96.633 E0.05810 G1 X121.414 Y96.633 E0.02234 G1 X120.713 Y97.334 E0.03590 ;BEFORE_LAYER_CHANGE G92 E0.0 ;1.8 G1 F8640.000 G1 X121.414 Y96.633 E-0.22876 G1 X122.030 Y96.633 E-0.14232 G1 X120.896 Y97.767 E-0.37021 G1 X120.896 Y97.848 E-0.01871 G1 E-0.04000 F2100.00000 G1 Z2.200 F10800.000 ;AFTER_LAYER_CHANGE ;1.8 G1 X147.855 Y96.299 G1 Z1.800 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X149.334 Y96.299 E0.05005 G1 X149.334 Y103.535 E0.24492 G1 X147.855 Y103.535 E0.05005 G1 X147.855 Y96.359 E0.24289 M204 S1000 G1 X147.448 Y95.892 F10800.000 M204 S800 G1 F900 G1 X149.741 Y95.892 E0.07761 G1 X149.741 Y103.942 E0.27248 G1 X147.448 Y103.942 E0.07761 G1 X147.448 Y95.952 E0.27045 M204 S1000 G1 X147.811 Y96.060 F10800.000 G1 F8640.000 G1 X149.741 Y95.892 E-0.52963 G1 X149.741 Y96.890 E-0.23037 G1 E-0.04000 F2100.00000 G1 Z2.400 F10800.000 G1 X148.827 Y103.413 G1 Z1.800 G1 E0.80000 F2100.00000 G1 F900 G1 X148.160 Y102.747 E0.03287 G1 X148.160 Y102.154 E0.02070 G1 X149.029 Y103.022 E0.04284 G1 X149.029 Y102.428 E0.02070 G1 X148.160 Y101.560 E0.04284 G1 X148.160 Y100.967 E0.02070 G1 X149.029 Y101.835 E0.04284 G1 X149.029 Y101.242 E0.02070 G1 X148.160 Y100.373 E0.04284 G1 X148.160 Y99.780 E0.02070 G1 X149.029 Y100.648 E0.04284 G1 X149.029 Y100.055 E0.02070 G1 X148.160 Y99.187 E0.04284 G1 X148.160 Y98.593 E0.02070 G1 X149.029 Y99.461 E0.04284 G1 X149.029 Y98.868 E0.02070 G1 X148.160 Y98.000 E0.04284 G1 X148.160 Y97.406 E0.02070 G1 X149.029 Y98.275 E0.04284 G1 X149.029 Y97.681 E0.02070 G1 X148.160 Y96.813 E0.04284 G1 X148.160 Y96.605 E0.00727 G1 X148.545 Y96.605 E0.01344 G1 X149.212 Y97.271 E0.03287 G1 F8640.000 G1 X148.545 Y96.605 E-0.21757 G1 X148.160 Y96.605 E-0.08892 G1 X148.160 Y96.813 E-0.04810 G1 X149.029 Y97.681 E-0.28350 G1 X149.029 Y98.209 E-0.12191 G1 E-0.04000 F2100.00000 G1 Z2.400 F10800.000 G1 X142.077 Y96.299 G1 Z1.800 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X142.077 Y103.535 E0.24492 G1 X140.598 Y103.535 E0.05005 G1 X140.598 Y96.299 E0.24492 G1 X142.017 Y96.299 E0.04802 M204 S1000 G1 X142.484 Y95.892 F10800.000 M204 S800 G1 F900 G1 X142.484 Y103.942 E0.27248 G1 X140.191 Y103.942 E0.07761 G1 X140.191 Y95.892 E0.27248 G1 X142.424 Y95.892 E0.07558 M204 S1000 G1 X142.447 Y96.291 F10800.000 G1 F8640.000 G1 X142.448 Y99.184 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z2.400 F10800.000 G1 X141.569 Y103.413 G1 Z1.800 G1 E0.80000 F2100.00000 G1 F900 G1 X140.903 Y102.747 E0.03287 G1 X140.903 Y102.154 E0.02070 G1 X141.772 Y103.022 E0.04284 G1 X141.772 Y102.428 E0.02070 G1 X140.903 Y101.560 E0.04284 G1 X140.903 Y100.967 E0.02070 G1 X141.772 Y101.835 E0.04284 G1 X141.772 Y101.242 E0.02070 G1 X140.903 Y100.373 E0.04284 G1 X140.903 Y99.780 E0.02070 G1 X141.772 Y100.648 E0.04284 G1 X141.772 Y100.055 E0.02070 G1 X140.903 Y99.187 E0.04284 G1 X140.903 Y98.593 E0.02070 G1 X141.772 Y99.461 E0.04284 G1 X141.772 Y98.868 E0.02070 G1 X140.903 Y98.000 E0.04284 G1 X140.903 Y97.406 E0.02070 G1 X141.772 Y98.275 E0.04284 G1 X141.772 Y97.681 E0.02070 G1 X140.903 Y96.813 E0.04284 G1 X140.903 Y96.605 E0.00727 G1 X141.288 Y96.605 E0.01344 G1 X141.955 Y97.271 E0.03287 G1 F8640.000 G1 X141.288 Y96.605 E-0.21757 G1 X140.903 Y96.605 E-0.08892 G1 X140.903 Y96.813 E-0.04810 G1 X141.772 Y97.681 E-0.28350 G1 X141.772 Y98.209 E-0.12191 G1 E-0.04000 F2100.00000 G1 Z2.400 F10800.000 G1 X129.327 Y96.328 G1 Z1.800 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X129.327 Y103.564 E0.24492 G1 X127.848 Y103.564 E0.05005 G1 X127.848 Y96.328 E0.24492 G1 X129.267 Y96.328 E0.04802 M204 S1000 G1 X129.734 Y95.921 F10800.000 M204 S800 G1 F900 G1 X129.734 Y103.971 E0.27248 G1 X127.441 Y103.971 E0.07761 G1 X127.441 Y95.921 E0.27248 G1 X129.674 Y95.921 E0.07558 M204 S1000 G1 X129.697 Y96.319 F10800.000 G1 F8640.000 G1 X129.698 Y99.212 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z2.400 F10800.000 G1 X128.819 Y103.442 G1 Z1.800 G1 E0.80000 F2100.00000 G1 F900 G1 X128.153 Y102.776 E0.03287 G1 X128.153 Y102.182 E0.02070 G1 X129.021 Y103.050 E0.04284 G1 X129.021 Y102.457 E0.02070 G1 X128.153 Y101.589 E0.04284 G1 X128.153 Y100.996 E0.02070 G1 X129.021 Y101.864 E0.04284 G1 X129.021 Y101.270 E0.02070 G1 X128.153 Y100.402 E0.04284 G1 X128.153 Y99.809 E0.02070 G1 X129.021 Y100.677 E0.04284 G1 X129.021 Y100.083 E0.02070 G1 X128.153 Y99.215 E0.04284 G1 X128.153 Y98.622 E0.02070 G1 X129.021 Y99.490 E0.04284 G1 X129.021 Y98.897 E0.02070 G1 X128.153 Y98.029 E0.04284 G1 X128.153 Y97.435 E0.02070 G1 X129.021 Y98.303 E0.04284 G1 X129.021 Y97.710 E0.02070 G1 X128.153 Y96.842 E0.04284 G1 X128.153 Y96.633 E0.00727 G1 X128.538 Y96.633 E0.01344 G1 X129.205 Y97.300 E0.03287 G1 F8640.000 G1 X128.538 Y96.633 E-0.21757 G1 X128.153 Y96.633 E-0.08892 G1 X128.153 Y96.842 E-0.04810 G1 X129.021 Y97.710 E-0.28350 G1 X129.021 Y98.238 E-0.12191 G1 E-0.04000 F2100.00000 G1 Z2.400 F10800.000 G1 X122.070 Y96.328 G1 Z1.800 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X122.070 Y103.564 E0.24492 G1 X120.591 Y103.564 E0.05005 G1 X120.591 Y96.328 E0.24492 G1 X122.010 Y96.328 E0.04802 M204 S1000 G1 X122.477 Y95.921 F10800.000 M204 S800 G1 F900 G1 X122.477 Y103.971 E0.27248 G1 X120.184 Y103.971 E0.07761 G1 X120.184 Y95.921 E0.27248 G1 X122.417 Y95.921 E0.07558 M204 S1000 G1 X122.440 Y96.319 F10800.000 G1 F8640.000 G1 X122.441 Y99.212 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z2.400 F10800.000 G1 X121.562 Y103.442 G1 Z1.800 G1 E0.80000 F2100.00000 G1 F900 G1 X120.896 Y102.776 E0.03287 G1 X120.896 Y102.182 E0.02070 G1 X121.764 Y103.050 E0.04284 G1 X121.764 Y102.457 E0.02070 G1 X120.896 Y101.589 E0.04284 G1 X120.896 Y100.996 E0.02070 G1 X121.764 Y101.864 E0.04284 G1 X121.764 Y101.270 E0.02070 G1 X120.896 Y100.402 E0.04284 G1 X120.896 Y99.809 E0.02070 G1 X121.764 Y100.677 E0.04284 G1 X121.764 Y100.083 E0.02070 G1 X120.896 Y99.215 E0.04284 G1 X120.896 Y98.622 E0.02070 G1 X121.764 Y99.490 E0.04284 G1 X121.764 Y98.897 E0.02070 G1 X120.896 Y98.029 E0.04284 G1 X120.896 Y97.435 E0.02070 G1 X121.764 Y98.303 E0.04284 G1 X121.764 Y97.710 E0.02070 G1 X120.896 Y96.842 E0.04284 G1 X120.896 Y96.633 E0.00727 G1 X121.281 Y96.633 E0.01344 G1 X121.948 Y97.300 E0.03287 ;BEFORE_LAYER_CHANGE G92 E0.0 ;2 G1 F8640.000 G1 X121.281 Y96.633 E-0.21757 G1 X120.896 Y96.633 E-0.08892 G1 X120.896 Y96.842 E-0.04810 G1 X121.764 Y97.710 E-0.28350 G1 X121.764 Y98.238 E-0.12191 G1 E-0.04000 F2100.00000 G1 Z2.400 F10800.000 ;AFTER_LAYER_CHANGE ;2 G1 X148.125 Y96.299 G1 Z2.000 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X149.334 Y96.299 E0.04093 G1 X149.334 Y103.535 E0.24492 G1 X148.125 Y103.535 E0.04093 G1 X148.125 Y96.359 E0.24289 M204 S1000 G1 X147.718 Y95.892 F10800.000 M204 S800 G1 F900 G1 X149.741 Y95.892 E0.06849 G1 X149.741 Y103.942 E0.27248 G1 X147.718 Y103.942 E0.06849 G1 X147.718 Y95.952 E0.27045 M204 S1000 G1 X148.079 Y96.063 F10800.000 G1 F8640.000 G1 X149.741 Y95.892 E-0.46742 G1 X149.741 Y97.159 E-0.29258 G1 E-0.04000 F2100.00000 G1 Z2.600 F10800.000 G1 X148.325 Y103.413 G1 Z2.000 G1 E0.80000 F2100.00000 G1 F900 G1 X149.029 Y102.710 E0.03618 G1 X149.029 Y102.091 E0.02248 G1 X148.430 Y102.690 E0.03078 G1 X148.430 Y102.072 E0.02248 G1 X149.029 Y101.473 E0.03078 G1 X149.029 Y100.855 E0.02248 G1 X148.430 Y101.453 E0.03078 G1 X148.430 Y100.835 E0.02248 G1 X149.029 Y100.236 E0.03078 G1 X149.029 Y99.618 E0.02248 G1 X148.430 Y100.217 E0.03078 G1 X148.430 Y99.598 E0.02248 G1 X149.029 Y99.000 E0.03078 G1 X149.029 Y98.381 E0.02248 G1 X148.430 Y98.980 E0.03078 G1 X148.430 Y98.362 E0.02248 G1 X149.029 Y97.763 E0.03078 G1 X149.029 Y97.145 E0.02248 G1 X148.430 Y97.743 E0.03078 G1 X148.430 Y97.125 E0.02248 G1 X149.133 Y96.422 E0.03617 G1 F8640.000 G1 X148.430 Y97.125 E-0.22973 G1 X148.430 Y97.743 E-0.14277 G1 X149.029 Y97.145 E-0.19550 G1 X149.029 Y97.763 E-0.14277 G1 X148.878 Y97.914 E-0.04923 G1 E-0.04000 F2100.00000 G1 Z2.600 F10800.000 G1 X141.807 Y96.422 G1 Z2.000 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X141.807 Y103.535 E0.24079 G1 X140.598 Y103.535 E0.04093 G1 X140.598 Y96.299 E0.24492 G1 X141.807 Y96.299 E0.04093 G1 X141.807 Y96.362 E0.00210 M204 S1000 G1 X142.214 Y95.892 F10800.000 M204 S800 G1 F900 G1 X142.214 Y103.942 E0.27248 G1 X140.191 Y103.942 E0.06849 G1 X140.191 Y95.892 E0.27248 G1 X142.154 Y95.892 E0.06646 M204 S1000 G1 X142.182 Y96.291 F10800.000 G1 F8640.000 G1 X142.179 Y99.184 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z2.600 F10800.000 G1 X140.798 Y103.413 G1 Z2.000 G1 E0.80000 F2100.00000 G1 F900 G1 X141.502 Y102.710 E0.03618 G1 X141.502 Y102.091 E0.02248 G1 X140.903 Y102.690 E0.03078 G1 X140.903 Y102.072 E0.02248 G1 X141.502 Y101.473 E0.03078 G1 X141.502 Y100.855 E0.02248 G1 X140.903 Y101.453 E0.03078 G1 X140.903 Y100.835 E0.02248 G1 X141.502 Y100.236 E0.03078 G1 X141.502 Y99.618 E0.02248 G1 X140.903 Y100.217 E0.03078 G1 X140.903 Y99.598 E0.02248 G1 X141.502 Y99.000 E0.03078 G1 X141.502 Y98.381 E0.02248 G1 X140.903 Y98.980 E0.03078 G1 X140.903 Y98.362 E0.02248 G1 X141.502 Y97.763 E0.03078 G1 X141.502 Y97.145 E0.02248 G1 X140.903 Y97.743 E0.03078 G1 X140.903 Y97.125 E0.02248 G1 X141.607 Y96.422 E0.03617 G1 F8640.000 G1 X140.903 Y97.125 E-0.22973 G1 X140.903 Y97.743 E-0.14277 G1 X141.502 Y97.145 E-0.19550 G1 X141.502 Y97.763 E-0.14277 G1 X141.351 Y97.914 E-0.04923 G1 E-0.04000 F2100.00000 G1 Z2.600 F10800.000 G1 X129.327 Y96.422 G1 Z2.000 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X129.327 Y103.564 E0.24176 G1 X128.117 Y103.564 E0.04093 G1 X128.117 Y96.328 E0.24492 G1 X129.327 Y96.328 E0.04093 G1 X129.327 Y96.362 E0.00113 M204 S1000 G1 X129.734 Y95.921 F10800.000 M204 S800 G1 F900 G1 X129.734 Y103.971 E0.27248 G1 X127.710 Y103.971 E0.06849 G1 X127.710 Y95.921 E0.27248 G1 X129.674 Y95.921 E0.06646 M204 S1000 G1 X129.701 Y96.320 F10800.000 G1 F8640.000 G1 X129.698 Y99.212 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z2.600 F10800.000 G1 X128.318 Y103.442 G1 Z2.000 G1 E0.80000 F2100.00000 G1 F900 G1 X129.021 Y102.738 E0.03618 G1 X129.021 Y102.120 E0.02248 G1 X128.423 Y102.719 E0.03078 G1 X128.423 Y102.100 E0.02248 G1 X129.021 Y101.502 E0.03078 G1 X129.021 Y100.883 E0.02248 G1 X128.423 Y101.482 E0.03078 G1 X128.423 Y100.864 E0.02248 G1 X129.021 Y100.265 E0.03078 G1 X129.021 Y99.647 E0.02248 G1 X128.423 Y100.245 E0.03078 G1 X128.423 Y99.627 E0.02248 G1 X129.021 Y99.028 E0.03078 G1 X129.021 Y98.410 E0.02248 G1 X128.423 Y99.009 E0.03078 G1 X128.423 Y98.390 E0.02248 G1 X129.021 Y97.792 E0.03078 G1 X129.021 Y97.173 E0.02248 G1 X128.423 Y97.772 E0.03078 G1 X128.423 Y97.154 E0.02248 G1 X129.126 Y96.450 E0.03617 G1 F8640.000 G1 X128.423 Y97.154 E-0.22973 G1 X128.423 Y97.772 E-0.14277 G1 X129.021 Y97.173 E-0.19550 G1 X129.021 Y97.792 E-0.14277 G1 X128.871 Y97.942 E-0.04923 G1 E-0.04000 F2100.00000 G1 Z2.600 F10800.000 G1 X121.800 Y96.450 G1 Z2.000 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X121.800 Y103.564 E0.24079 G1 X120.591 Y103.564 E0.04093 G1 X120.591 Y96.328 E0.24492 G1 X121.800 Y96.328 E0.04093 G1 X121.800 Y96.390 E0.00210 M204 S1000 G1 X122.207 Y95.921 F10800.000 M204 S800 G1 F900 G1 X122.207 Y103.971 E0.27248 G1 X120.184 Y103.971 E0.06849 G1 X120.184 Y95.921 E0.27248 G1 X122.147 Y95.921 E0.06646 M204 S1000 G1 X122.174 Y96.320 F10800.000 G1 F8640.000 G1 X122.172 Y99.212 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z2.600 F10800.000 G1 X120.791 Y103.442 G1 Z2.000 G1 E0.80000 F2100.00000 G1 F900 G1 X121.495 Y102.738 E0.03618 G1 X121.495 Y102.120 E0.02248 G1 X120.896 Y102.719 E0.03078 G1 X120.896 Y102.100 E0.02248 G1 X121.495 Y101.502 E0.03078 G1 X121.495 Y100.883 E0.02248 G1 X120.896 Y101.482 E0.03078 G1 X120.896 Y100.864 E0.02248 G1 X121.495 Y100.265 E0.03078 G1 X121.495 Y99.647 E0.02248 G1 X120.896 Y100.245 E0.03078 G1 X120.896 Y99.627 E0.02248 G1 X121.495 Y99.028 E0.03078 G1 X121.495 Y98.410 E0.02248 G1 X120.896 Y99.009 E0.03078 G1 X120.896 Y98.390 E0.02248 G1 X121.495 Y97.792 E0.03078 G1 X121.495 Y97.173 E0.02248 G1 X120.896 Y97.772 E0.03078 G1 X120.896 Y97.154 E0.02248 G1 X121.600 Y96.450 E0.03617 ;BEFORE_LAYER_CHANGE G92 E0.0 ;2.2 G1 F8640.000 G1 X120.896 Y97.154 E-0.22973 G1 X120.896 Y97.772 E-0.14277 G1 X121.495 Y97.173 E-0.19550 G1 X121.495 Y97.792 E-0.14277 G1 X121.344 Y97.942 E-0.04923 G1 E-0.04000 F2100.00000 G1 Z2.600 F10800.000 ;AFTER_LAYER_CHANGE ;2.2 G1 X148.352 Y96.299 G1 Z2.200 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X149.334 Y96.299 E0.03323 G1 X149.334 Y103.535 E0.24492 G1 X148.352 Y103.535 E0.03323 G1 X148.352 Y96.359 E0.24289 M204 S1000 G1 X147.945 Y95.892 F10800.000 M204 S800 G1 F900 G1 X149.741 Y95.892 E0.06079 G1 X149.741 Y103.942 E0.27248 G1 X147.945 Y103.942 E0.06079 M73 Q18 S18 G1 X147.945 Y95.952 E0.27045 M204 S1000 G1 X148.305 Y96.067 F10800.000 G1 F8640.000 G1 X149.741 Y95.892 E-0.41492 G1 X149.741 Y97.387 E-0.34508 G1 E-0.04000 F2100.00000 G1 Z2.800 F10800.000 G1 X148.474 Y102.553 G1 Z2.200 G1 E0.80000 F2100.00000 M73 P18 R18 G1 F900 G1 X149.029 Y103.107 E0.02769 G1 X149.029 Y102.506 E0.02122 G1 X148.657 Y102.135 E0.01854 G1 X148.657 Y101.534 E0.02122 G1 X149.029 Y101.905 E0.01854 G1 X149.029 Y101.305 E0.02122 G1 X148.657 Y100.933 E0.01854 G1 X148.657 Y100.333 E0.02122 G1 X149.029 Y100.704 E0.01854 G1 X149.029 Y100.103 E0.02122 G1 X148.657 Y99.732 E0.01854 G1 X148.657 Y99.131 E0.02122 G1 X149.029 Y99.502 E0.01854 G1 X149.029 Y98.901 E0.02122 G1 X148.657 Y98.530 E0.01854 G1 X148.657 Y97.929 E0.02122 G1 X149.029 Y98.301 E0.01854 G1 X149.029 Y97.700 E0.02122 G1 X148.657 Y97.329 E0.01854 G1 X148.657 Y96.728 E0.02122 G1 X149.212 Y97.282 E0.02769 G1 F8640.000 G1 X148.657 Y96.728 E-0.18102 G1 X148.657 Y97.329 E-0.13873 G1 X149.029 Y97.700 E-0.12121 G1 X149.029 Y98.301 E-0.13873 G1 X148.657 Y97.929 E-0.12121 G1 X148.657 Y98.185 E-0.05910 G1 E-0.04000 F2100.00000 G1 Z2.800 F10800.000 G1 X141.580 Y96.299 G1 Z2.200 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X141.580 Y103.535 E0.24492 G1 X140.598 Y103.535 E0.03323 G1 X140.598 Y96.299 E0.24492 G1 X141.520 Y96.299 E0.03120 M204 S1000 G1 X141.987 Y95.892 F10800.000 M204 S800 G1 F900 G1 X141.987 Y103.942 E0.27248 G1 X140.191 Y103.942 E0.06079 G1 X140.191 Y95.892 E0.27248 G1 X141.927 Y95.892 E0.05876 M204 S1000 G1 X141.958 Y96.291 F10800.000 G1 F8640.000 G1 X141.951 Y99.184 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z2.800 F10800.000 G1 X140.720 Y102.553 G1 Z2.200 G1 E0.80000 F2100.00000 G1 F900 G1 X141.275 Y103.107 E0.02769 G1 X141.275 Y102.506 E0.02122 G1 X140.903 Y102.135 E0.01854 G1 X140.903 Y101.534 E0.02122 G1 X141.275 Y101.905 E0.01854 G1 X141.275 Y101.305 E0.02122 G1 X140.903 Y100.933 E0.01854 G1 X140.903 Y100.333 E0.02122 G1 X141.275 Y100.704 E0.01854 G1 X141.275 Y100.103 E0.02122 G1 X140.903 Y99.732 E0.01854 G1 X140.903 Y99.131 E0.02122 G1 X141.275 Y99.502 E0.01854 G1 X141.275 Y98.901 E0.02122 G1 X140.903 Y98.530 E0.01854 G1 X140.903 Y97.929 E0.02122 G1 X141.275 Y98.301 E0.01854 G1 X141.275 Y97.700 E0.02122 G1 X140.903 Y97.329 E0.01854 G1 X140.903 Y96.728 E0.02122 G1 X141.458 Y97.282 E0.02769 G1 F8640.000 G1 X140.903 Y96.728 E-0.18102 G1 X140.903 Y97.329 E-0.13873 G1 X141.275 Y97.700 E-0.12121 G1 X141.275 Y98.301 E-0.13873 G1 X140.903 Y97.929 E-0.12121 G1 X140.903 Y98.185 E-0.05911 G1 E-0.04000 F2100.00000 G1 Z2.800 F10800.000 G1 X129.327 Y96.328 G1 Z2.200 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X129.327 Y103.564 E0.24492 G1 X128.345 Y103.564 E0.03323 G1 X128.345 Y96.328 E0.24492 G1 X129.267 Y96.328 E0.03120 M204 S1000 G1 X129.734 Y95.921 F10800.000 M204 S800 G1 F900 G1 X129.734 Y103.971 E0.27248 G1 X127.938 Y103.971 E0.06079 G1 X127.938 Y95.921 E0.27248 G1 X129.674 Y95.921 E0.05876 M204 S1000 G1 X129.705 Y96.320 F10800.000 G1 F8640.000 G1 X129.698 Y99.212 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z2.800 F10800.000 G1 X128.467 Y102.581 G1 Z2.200 G1 E0.80000 F2100.00000 G1 F900 G1 X129.021 Y103.136 E0.02769 G1 X129.021 Y102.535 E0.02122 G1 X128.650 Y102.164 E0.01854 G1 X128.650 Y101.563 E0.02122 G1 X129.021 Y101.934 E0.01854 G1 X129.021 Y101.333 E0.02122 G1 X128.650 Y100.962 E0.01854 G1 X128.650 Y100.361 E0.02122 G1 X129.021 Y100.733 E0.01854 G1 X129.021 Y100.132 E0.02122 G1 X128.650 Y99.761 E0.01854 G1 X128.650 Y99.160 E0.02122 G1 X129.021 Y99.531 E0.01854 G1 X129.021 Y98.930 E0.02122 G1 X128.650 Y98.559 E0.01854 G1 X128.650 Y97.958 E0.02122 G1 X129.021 Y98.329 E0.01854 G1 X129.021 Y97.728 E0.02122 G1 X128.650 Y97.357 E0.01854 G1 X128.650 Y96.756 E0.02122 G1 X129.205 Y97.311 E0.02769 G1 F8640.000 G1 X128.650 Y96.756 E-0.18102 G1 X128.650 Y97.357 E-0.13873 G1 X129.021 Y97.728 E-0.12121 G1 X129.021 Y98.329 E-0.13873 G1 X128.650 Y97.958 E-0.12121 G1 X128.650 Y98.214 E-0.05910 G1 E-0.04000 F2100.00000 G1 Z2.800 F10800.000 G1 X121.573 Y96.328 G1 Z2.200 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X121.573 Y103.564 E0.24492 G1 X120.591 Y103.564 E0.03323 G1 X120.591 Y96.328 E0.24492 G1 X121.513 Y96.328 E0.03120 M204 S1000 G1 X121.980 Y95.921 F10800.000 M204 S800 G1 F900 G1 X121.980 Y103.971 E0.27248 G1 X120.184 Y103.971 E0.06079 G1 X120.184 Y95.921 E0.27248 G1 X121.920 Y95.921 E0.05876 M204 S1000 G1 X121.951 Y96.320 F10800.000 G1 F8640.000 G1 X121.944 Y99.212 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z2.800 F10800.000 G1 X120.713 Y102.581 G1 Z2.200 G1 E0.80000 F2100.00000 G1 F900 G1 X121.267 Y103.136 E0.02769 G1 X121.267 Y102.535 E0.02122 G1 X120.896 Y102.164 E0.01854 G1 X120.896 Y101.563 E0.02122 G1 X121.267 Y101.934 E0.01854 G1 X121.267 Y101.333 E0.02122 G1 X120.896 Y100.962 E0.01854 G1 X120.896 Y100.361 E0.02122 G1 X121.267 Y100.733 E0.01854 G1 X121.267 Y100.132 E0.02122 G1 X120.896 Y99.761 E0.01854 G1 X120.896 Y99.160 E0.02122 G1 X121.267 Y99.531 E0.01854 G1 X121.267 Y98.930 E0.02122 G1 X120.896 Y98.559 E0.01854 G1 X120.896 Y97.958 E0.02122 G1 X121.267 Y98.329 E0.01854 G1 X121.267 Y97.728 E0.02122 G1 X120.896 Y97.357 E0.01854 G1 X120.896 Y96.756 E0.02122 G1 X121.451 Y97.311 E0.02769 ;BEFORE_LAYER_CHANGE G92 E0.0 ;2.4 G1 F8640.000 G1 X120.896 Y96.756 E-0.18102 G1 X120.896 Y97.357 E-0.13873 G1 X121.267 Y97.728 E-0.12121 G1 X121.267 Y98.329 E-0.13873 G1 X120.896 Y97.958 E-0.12121 G1 X120.896 Y98.214 E-0.05911 G1 E-0.04000 F2100.00000 G1 Z2.800 F10800.000 ;AFTER_LAYER_CHANGE ;2.4 G1 X148.548 Y96.299 G1 Z2.400 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X149.334 Y96.299 E0.02662 G1 X149.334 Y103.535 E0.24492 G1 X148.548 Y103.535 E0.02662 G1 X148.548 Y96.359 E0.24289 M204 S1000 G1 X148.141 Y95.892 F10800.000 M204 S800 G1 F900 G1 X149.741 Y95.892 E0.05417 G1 X149.741 Y103.942 E0.27248 G1 X148.141 Y103.942 E0.05417 G1 X148.141 Y95.952 E0.27045 M204 S1000 G1 X148.499 Y96.069 F10800.000 G1 F8640.000 G1 X149.741 Y95.892 E-0.36981 G1 X149.741 Y97.582 E-0.39019 G1 E-0.04000 F2100.00000 G1 Z3.000 F10800.000 G1 X148.941 Y103.332 G1 Z2.400 G1 E0.80000 F2100.00000 G1 F900 G1 X148.941 Y96.503 E0.21533 G1 F8640.000 G1 X148.941 Y99.794 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z3.000 F10800.000 G1 X141.384 Y96.299 G1 Z2.400 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X141.384 Y103.535 E0.24492 G1 X140.598 Y103.535 E0.02662 G1 X140.598 Y96.299 E0.24492 G1 X141.324 Y96.299 E0.02458 M204 S1000 G1 X141.791 Y95.892 F10800.000 M204 S800 G1 F900 G1 X141.791 Y103.942 E0.27248 G1 X140.191 Y103.942 E0.05417 G1 X140.191 Y95.892 E0.27248 G1 X141.731 Y95.892 E0.05214 M204 S1000 G1 X141.765 Y96.292 F10800.000 G1 F8640.000 G1 X141.756 Y99.184 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z3.000 F10800.000 G1 X140.991 Y103.332 G1 Z2.400 G1 E0.80000 F2100.00000 G1 F900 G1 X140.991 Y96.503 E0.21533 G1 F8640.000 G1 X140.991 Y99.794 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z3.000 F10800.000 G1 X129.327 Y96.503 G1 Z2.400 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X129.327 Y103.564 E0.23901 G1 X128.540 Y103.564 E0.02662 G1 X128.540 Y96.328 E0.24492 G1 X129.327 Y96.328 E0.02662 G1 X129.327 Y96.443 E0.00389 M204 S1000 G1 X129.734 Y95.921 F10800.000 M204 S800 G1 F900 G1 X129.734 Y103.971 E0.27248 G1 X128.133 Y103.971 E0.05417 G1 X128.133 Y95.921 E0.27248 G1 X129.674 Y95.921 E0.05214 M204 S1000 G1 X129.708 Y96.320 F10800.000 G1 F8640.000 G1 X129.698 Y99.212 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z3.000 F10800.000 G1 X128.934 Y103.360 G1 Z2.400 G1 E0.80000 F2100.00000 G1 F900 G1 X128.934 Y96.532 E0.21533 G1 F8640.000 G1 X128.934 Y99.823 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z3.000 F10800.000 G1 X121.377 Y96.328 G1 Z2.400 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X121.377 Y103.564 E0.24492 G1 X120.591 Y103.564 E0.02662 G1 X120.591 Y96.328 E0.24492 G1 X121.317 Y96.328 E0.02458 M204 S1000 G1 X121.784 Y95.921 F10800.000 M204 S800 G1 F900 G1 X121.784 Y103.971 E0.27248 G1 X120.184 Y103.971 E0.05417 G1 X120.184 Y95.921 E0.27248 G1 X121.724 Y95.921 E0.05214 M204 S1000 G1 X121.758 Y96.320 F10800.000 G1 F8640.000 G1 X121.749 Y99.212 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z3.000 F10800.000 G1 X120.984 Y103.360 G1 Z2.400 G1 E0.80000 F2100.00000 G1 F900 G1 X120.984 Y96.532 E0.21533 ;BEFORE_LAYER_CHANGE G92 E0.0 ;2.6 G1 F8640.000 G1 X120.984 Y99.823 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z3.000 F10800.000 ;AFTER_LAYER_CHANGE ;2.6 G1 X149.334 Y103.535 G1 Z2.600 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X148.719 Y103.535 E0.02083 G1 X148.719 Y96.299 E0.24492 G1 X149.334 Y96.299 E0.02083 G1 X149.334 Y103.475 E0.24289 M204 S1000 G1 X149.741 Y103.942 F10800.000 M204 S800 G1 F900 G1 X148.312 Y103.942 E0.04838 G1 X148.312 Y95.892 E0.27248 G1 X149.741 Y95.892 E0.04838 G1 X149.741 Y103.882 E0.27045 M204 S1000 G1 X149.383 Y103.763 F10800.000 G1 F8640.000 G1 X148.312 Y103.942 E-0.33034 G1 X148.312 Y102.082 E-0.42966 G1 E-0.04000 F2100.00000 G1 Z3.200 F10800.000 G1 X149.026 Y96.503 G1 Z2.600 G1 E0.80000 F2100.00000 G1 F900 G1 X149.026 Y103.332 E0.11820 G1 F8640.000 G1 X149.026 Y100.040 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z3.200 F10800.000 G1 X141.213 Y103.535 G1 Z2.600 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X140.598 Y103.535 E0.02083 G1 X140.598 Y96.299 E0.24492 G1 X141.213 Y96.299 E0.02083 G1 X141.213 Y103.475 E0.24289 M204 S1000 G1 X141.620 Y103.942 F10800.000 M204 S800 G1 F900 G1 X140.191 Y103.942 E0.04838 G1 X140.191 Y95.892 E0.27248 G1 X141.620 Y95.892 E0.04838 G1 X141.620 Y103.882 E0.27045 M204 S1000 G1 X141.263 Y103.763 F10800.000 G1 F8640.000 G1 X140.191 Y103.942 E-0.33034 G1 X140.191 Y102.082 E-0.42966 G1 E-0.04000 F2100.00000 G1 Z3.200 F10800.000 G1 X140.906 Y96.503 G1 Z2.600 G1 E0.80000 F2100.00000 G1 F900 G1 X140.906 Y103.332 E0.11820 G1 F8640.000 G1 X140.906 Y100.040 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z3.200 F10800.000 G1 X129.327 Y103.564 G1 Z2.600 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X128.712 Y103.564 E0.02083 G1 X128.712 Y96.328 E0.24492 G1 X129.327 Y96.328 E0.02083 G1 X129.327 Y103.504 E0.24289 M204 S1000 G1 X129.734 Y103.971 F10800.000 M204 S800 G1 F900 G1 X128.304 Y103.971 E0.04838 G1 X128.304 Y95.921 E0.27248 G1 X129.734 Y95.921 E0.04838 G1 X129.734 Y103.911 E0.27045 M204 S1000 G1 X129.376 Y103.792 F10800.000 G1 F8640.000 G1 X128.304 Y103.971 E-0.33034 G1 X128.304 Y102.110 E-0.42966 G1 E-0.04000 F2100.00000 G1 Z3.200 F10800.000 G1 X129.019 Y96.532 G1 Z2.600 G1 E0.80000 F2100.00000 G1 F900 G1 X129.019 Y103.360 E0.11820 G1 F8640.000 G1 X129.019 Y100.069 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z3.200 F10800.000 G1 X121.206 Y103.564 G1 Z2.600 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X120.591 Y103.564 E0.02083 G1 X120.591 Y96.328 E0.24492 G1 X121.206 Y96.328 E0.02083 G1 X121.206 Y103.504 E0.24289 M204 S1000 G1 X121.613 Y103.971 F10800.000 M204 S800 G1 F900 G1 X120.184 Y103.971 E0.04838 G1 X120.184 Y95.921 E0.27248 G1 X121.613 Y95.921 E0.04838 G1 X121.613 Y103.911 E0.27045 M204 S1000 G1 X121.256 Y103.792 F10800.000 G1 F8640.000 G1 X120.184 Y103.971 E-0.33034 G1 X120.184 Y102.110 E-0.42966 G1 E-0.04000 F2100.00000 G1 Z3.200 F10800.000 G1 X120.899 Y96.532 G1 Z2.600 G1 E0.80000 F2100.00000 G1 F900 G1 X120.899 Y103.360 E0.11820 ;BEFORE_LAYER_CHANGE G92 E0.0 ;2.8 G1 F8640.000 G1 X120.899 Y100.069 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z3.200 F10800.000 ;AFTER_LAYER_CHANGE ;2.8 G1 X149.334 Y103.535 G1 Z2.800 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X148.869 Y103.535 E0.01574 G1 X148.869 Y96.299 E0.24492 G1 X149.334 Y96.299 E0.01574 G1 X149.334 Y103.475 E0.24289 M204 S1000 G1 X149.741 Y103.942 F10800.000 M204 S800 G1 F900 G1 X148.462 Y103.942 E0.04330 G1 X148.462 Y95.892 E0.27248 G1 X149.741 Y95.892 E0.04330 G1 X149.741 Y103.882 E0.27045 M204 S1000 G1 X149.385 Y103.761 F10800.000 G1 F8640.000 G1 X148.462 Y103.942 E-0.29569 G1 X148.462 Y101.932 E-0.46431 G1 E-0.04000 F2100.00000 G1 Z3.400 F10800.000 G1 X149.101 Y96.503 G1 Z2.800 G1 E0.80000 F2100.00000 G1 F900 G1 X149.101 Y103.332 E0.03290 G1 F8640.000 G1 X149.101 Y100.040 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z3.400 F10800.000 G1 X141.063 Y103.535 G1 Z2.800 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X140.598 Y103.535 E0.01574 G1 X140.598 Y96.299 E0.24492 G1 X141.063 Y96.299 E0.01574 G1 X141.063 Y103.475 E0.24289 M204 S1000 G1 X141.470 Y103.942 F10800.000 M204 S800 G1 F900 G1 X140.191 Y103.942 E0.04330 G1 X140.191 Y95.892 E0.27248 G1 X141.470 Y95.892 E0.04330 G1 X141.470 Y103.882 E0.27045 M204 S1000 G1 X141.114 Y103.761 F10800.000 G1 F8640.000 G1 X140.191 Y103.942 E-0.29569 G1 X140.191 Y101.932 E-0.46431 G1 E-0.04000 F2100.00000 G1 Z3.400 F10800.000 G1 X140.831 Y96.503 G1 Z2.800 G1 E0.80000 F2100.00000 G1 F900 G1 X140.831 Y103.332 E0.03290 G1 F8640.000 G1 X140.831 Y100.040 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z3.400 F10800.000 G1 X129.327 Y103.564 G1 Z2.800 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X128.862 Y103.564 E0.01574 G1 X128.862 Y96.328 E0.24492 G1 X129.327 Y96.328 E0.01574 G1 X129.327 Y103.504 E0.24289 M204 S1000 G1 X129.734 Y103.971 F10800.000 M204 S800 G1 F900 G1 X128.455 Y103.971 E0.04330 G1 X128.455 Y95.921 E0.27248 G1 X129.734 Y95.921 E0.04330 G1 X129.734 Y103.911 E0.27045 M204 S1000 G1 X129.377 Y103.790 F10800.000 G1 F8640.000 G1 X128.455 Y103.971 E-0.29569 G1 X128.455 Y101.960 E-0.46431 G1 E-0.04000 F2100.00000 G1 Z3.400 F10800.000 G1 X129.094 Y96.532 G1 Z2.800 G1 E0.80000 F2100.00000 G1 F900 G1 X129.094 Y103.360 E0.03290 G1 F8640.000 G1 X129.094 Y100.069 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z3.400 F10800.000 G1 X121.056 Y103.564 G1 Z2.800 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X120.591 Y103.564 E0.01574 G1 X120.591 Y96.328 E0.24492 G1 X121.056 Y96.328 E0.01574 G1 X121.056 Y103.504 E0.24289 M204 S1000 G1 X121.463 Y103.971 F10800.000 M204 S800 G1 F900 G1 X120.184 Y103.971 E0.04330 G1 X120.184 Y95.921 E0.27248 G1 X121.463 Y95.921 E0.04330 G1 X121.463 Y103.911 E0.27045 M204 S1000 G1 X121.107 Y103.790 F10800.000 G1 F8640.000 G1 X120.184 Y103.971 E-0.29569 G1 X120.184 Y101.960 E-0.46431 G1 E-0.04000 F2100.00000 G1 Z3.400 F10800.000 G1 X120.823 Y96.532 G1 Z2.800 G1 E0.80000 F2100.00000 G1 F900 G1 X120.823 Y103.360 E0.03290 M73 Q23 S17 ;BEFORE_LAYER_CHANGE G92 E0.0 ;3 G1 F8640.000 G1 X120.823 Y100.069 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z3.400 F10800.000 ;AFTER_LAYER_CHANGE ;3 G1 X149.334 Y103.535 G1 Z3.000 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X149.001 Y103.535 E0.01127 G1 X149.001 Y96.299 E0.24492 M73 P23 R17 G1 X149.334 Y96.299 E0.01127 G1 X149.334 Y103.475 E0.24289 M204 S1000 G1 X149.741 Y103.942 F10800.000 M204 S800 G1 F900 G1 X148.594 Y103.942 E0.03883 G1 X148.594 Y95.892 E0.27248 G1 X149.741 Y95.892 E0.03883 G1 X149.741 Y103.882 E0.27045 M204 S1000 G1 X149.386 Y103.759 F10800.000 G1 F8640.000 G1 X148.594 Y103.942 E-0.26523 G1 X148.594 Y101.800 E-0.49478 G1 E-0.04000 F2100.00000 G1 Z3.600 F10800.000 G1 X140.931 Y103.535 G1 Z3.000 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X140.598 Y103.535 E0.01127 G1 X140.598 Y96.299 E0.24492 G1 X140.931 Y96.299 E0.01127 G1 X140.931 Y103.475 E0.24289 M204 S1000 G1 X141.338 Y103.942 F10800.000 M204 S800 G1 F900 G1 X140.191 Y103.942 E0.03883 G1 X140.191 Y95.892 E0.27248 G1 X141.338 Y95.892 E0.03883 G1 X141.338 Y103.882 E0.27045 M204 S1000 G1 X140.983 Y103.759 F10800.000 G1 F8640.000 G1 X140.191 Y103.942 E-0.26523 G1 X140.191 Y101.800 E-0.49478 G1 E-0.04000 F2100.00000 G1 Z3.600 F10800.000 G1 X129.327 Y103.564 G1 Z3.000 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X128.994 Y103.564 E0.01127 G1 X128.994 Y96.328 E0.24492 G1 X129.327 Y96.328 E0.01127 G1 X129.327 Y103.504 E0.24289 M204 S1000 G1 X129.734 Y103.971 F10800.000 M204 S800 G1 F900 G1 X128.587 Y103.971 E0.03883 G1 X128.587 Y95.921 E0.27248 G1 X129.734 Y95.921 E0.03883 G1 X129.734 Y103.911 E0.27045 M204 S1000 G1 X129.378 Y103.788 F10800.000 G1 F8640.000 G1 X128.587 Y103.971 E-0.26523 G1 X128.587 Y101.828 E-0.49478 G1 E-0.04000 F2100.00000 G1 Z3.600 F10800.000 G1 X120.924 Y103.564 G1 Z3.000 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X120.591 Y103.564 E0.01127 G1 X120.591 Y96.328 E0.24492 G1 X120.924 Y96.328 E0.01127 G1 X120.924 Y103.504 E0.24289 M204 S1000 G1 X121.331 Y103.971 F10800.000 M204 S800 G1 F900 G1 X120.184 Y103.971 E0.03883 G1 X120.184 Y95.921 E0.27248 G1 X121.331 Y95.921 E0.03883 G1 X121.331 Y103.911 E0.27045 M204 S1000 G1 X120.975 Y103.788 F10800.000 ;BEFORE_LAYER_CHANGE G92 E0.0 ;3.2 G1 F8640.000 G1 X120.184 Y103.971 E-0.26523 G1 X120.184 Y101.828 E-0.49478 G1 E-0.04000 F2100.00000 G1 Z3.600 F10800.000 ;AFTER_LAYER_CHANGE ;3.2 G1 X149.117 Y103.535 G1 Z3.200 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X149.117 Y96.299 E0.24492 G1 X149.334 Y96.299 E0.00734 G1 X149.334 Y103.535 E0.24492 G1 X149.177 Y103.535 E0.00531 M204 S1000 G1 X148.710 Y103.942 F10800.000 M204 S800 G1 F900 G1 X148.710 Y95.892 E0.27248 G1 X149.741 Y95.892 E0.03490 G1 X149.741 Y103.942 E0.27248 G1 X148.770 Y103.942 E0.03287 M204 S1000 G1 X148.727 Y103.543 F10800.000 G1 F8640.000 G1 X148.745 Y100.651 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z3.800 F10800.000 G1 X140.815 Y103.535 G1 Z3.200 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X140.598 Y103.535 E0.00734 G1 X140.598 Y96.299 E0.24492 G1 X140.815 Y96.299 E0.00734 G1 X140.815 Y103.475 E0.24289 M204 S1000 G1 X141.222 Y103.942 F10800.000 M204 S800 G1 F900 G1 X140.191 Y103.942 E0.03490 G1 X140.191 Y95.892 E0.27248 G1 X141.222 Y95.892 E0.03490 G1 X141.222 Y103.882 E0.27045 M204 S1000 G1 X140.867 Y103.757 F10800.000 G1 F8640.000 G1 X140.191 Y103.942 E-0.23846 G1 X140.191 Y101.684 E-0.52154 G1 E-0.04000 F2100.00000 G1 Z3.800 F10800.000 G1 X129.327 Y103.564 G1 Z3.200 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X129.110 Y103.564 E0.00734 G1 X129.110 Y96.328 E0.24492 G1 X129.327 Y96.328 E0.00734 G1 X129.327 Y103.504 E0.24289 M204 S1000 G1 X129.734 Y103.971 F10800.000 M204 S800 G1 F900 G1 X128.703 Y103.971 E0.03490 G1 X128.703 Y95.921 E0.27248 G1 X129.734 Y95.921 E0.03490 G1 X129.734 Y103.911 E0.27045 M204 S1000 G1 X129.379 Y103.786 F10800.000 G1 F8640.000 G1 X128.703 Y103.971 E-0.23846 G1 X128.703 Y101.712 E-0.52154 G1 E-0.04000 F2100.00000 G1 Z3.800 F10800.000 G1 X120.808 Y103.564 G1 Z3.200 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X120.591 Y103.564 E0.00734 G1 X120.591 Y96.328 E0.24492 G1 X120.808 Y96.328 E0.00734 G1 X120.808 Y103.504 E0.24289 M204 S1000 G1 X121.215 Y103.971 F10800.000 M204 S800 G1 F900 G1 X120.184 Y103.971 E0.03490 G1 X120.184 Y95.921 E0.27248 G1 X121.215 Y95.921 E0.03490 G1 X121.215 Y103.911 E0.27045 M204 S1000 G1 X120.860 Y103.786 F10800.000 ;BEFORE_LAYER_CHANGE G92 E0.0 ;3.4 G1 F8640.000 G1 X120.184 Y103.971 E-0.23846 G1 X120.184 Y101.712 E-0.52154 G1 E-0.04000 F2100.00000 G1 Z3.800 F10800.000 ;AFTER_LAYER_CHANGE ;3.4 G1 X149.219 Y103.535 G1 Z3.400 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X149.219 Y96.299 E0.24492 G1 X149.334 Y96.299 E0.00390 G1 X149.334 Y103.535 E0.24492 G1 X149.279 Y103.535 E0.00187 M204 S1000 G1 X149.741 Y103.942 F10800.000 M204 S800 G1 F900 G1 X148.812 Y103.942 E0.03146 G1 X148.812 Y95.892 E0.27248 G1 X149.741 Y95.892 E0.03146 G1 X149.741 Y103.882 E0.27045 M204 S1000 G1 X149.387 Y103.756 F10800.000 G1 F8640.000 G1 X148.812 Y103.942 E-0.21503 G1 X148.812 Y101.582 E-0.54497 G1 E-0.04000 F2100.00000 G1 Z4.000 F10800.000 G1 X140.713 Y103.535 G1 Z3.400 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X140.598 Y103.535 E0.00390 G1 X140.598 Y96.299 E0.24492 G1 X140.713 Y96.299 E0.00390 G1 X140.713 Y103.475 E0.24289 M204 S1000 G1 X141.120 Y103.942 F10800.000 M204 S800 G1 F900 G1 X140.191 Y103.942 E0.03146 G1 X140.191 Y95.892 E0.27248 G1 X141.120 Y95.892 E0.03146 G1 X141.120 Y103.882 E0.27045 M204 S1000 G1 X140.766 Y103.756 F10800.000 G1 F8640.000 G1 X140.191 Y103.942 E-0.21503 G1 X140.191 Y101.582 E-0.54497 G1 E-0.04000 F2100.00000 G1 Z4.000 F10800.000 G1 X129.327 Y103.564 G1 Z3.400 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X129.212 Y103.564 E0.00390 G1 X129.212 Y96.328 E0.24492 G1 X129.327 Y96.328 E0.00390 G1 X129.327 Y103.504 E0.24289 M204 S1000 G1 X129.734 Y103.971 F10800.000 M204 S800 G1 F900 G1 X128.805 Y103.971 E0.03146 G1 X128.805 Y95.921 E0.27248 G1 X129.734 Y95.921 E0.03146 G1 X129.734 Y103.911 E0.27045 M204 S1000 G1 X129.380 Y103.784 F10800.000 G1 F8640.000 G1 X128.805 Y103.971 E-0.21503 G1 X128.805 Y101.611 E-0.54497 G1 E-0.04000 F2100.00000 G1 Z4.000 F10800.000 G1 X120.706 Y103.564 G1 Z3.400 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X120.591 Y103.564 E0.00390 G1 X120.591 Y96.328 E0.24492 G1 X120.706 Y96.328 E0.00390 G1 X120.706 Y103.504 E0.24289 M204 S1000 G1 X121.113 Y103.971 F10800.000 M204 S800 G1 F900 G1 X120.184 Y103.971 E0.03146 G1 X120.184 Y95.921 E0.27248 G1 X121.113 Y95.921 E0.03146 G1 X121.113 Y103.911 E0.27045 M204 S1000 G1 X120.759 Y103.784 F10800.000 ;BEFORE_LAYER_CHANGE G92 E0.0 ;3.6 G1 F8640.000 G1 X120.184 Y103.971 E-0.21503 G1 X120.184 Y101.611 E-0.54497 G1 E-0.04000 F2100.00000 G1 Z4.000 F10800.000 ;AFTER_LAYER_CHANGE ;3.6 G1 X149.305 Y103.535 G1 Z3.600 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X149.305 Y96.299 E0.24492 G1 X149.334 Y96.299 E0.00097 G1 X149.334 Y103.504 E0.24386 M204 S1000 G1 X149.741 Y103.942 F10800.000 M204 S800 G1 F900 G1 X148.898 Y103.942 E0.02853 G1 X148.898 Y95.892 E0.27248 G1 X149.741 Y95.892 E0.02853 G1 X149.741 Y103.882 E0.27045 M204 S1000 G1 X149.388 Y103.755 F10800.000 G1 F8640.000 G1 X148.898 Y103.942 E-0.19510 G1 X148.898 Y101.496 E-0.56490 G1 E-0.04000 F2100.00000 G1 Z4.200 F10800.000 G1 X140.627 Y103.535 G1 Z3.600 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X140.598 Y103.535 E0.00097 G1 X140.598 Y96.299 E0.24492 G1 X140.627 Y96.299 E0.00097 G1 X140.627 Y103.475 E0.24289 M204 S1000 G1 X141.034 Y103.942 F10800.000 M204 S800 G1 F900 G1 X140.191 Y103.942 E0.02853 G1 X140.191 Y95.892 E0.27248 G1 X141.034 Y95.892 E0.02853 G1 X141.034 Y103.882 E0.27045 M204 S1000 G1 X140.681 Y103.755 F10800.000 G1 F8640.000 G1 X140.191 Y103.942 E-0.19510 G1 X140.191 Y101.496 E-0.56490 G1 E-0.04000 F2100.00000 G1 Z4.200 F10800.000 G1 X129.327 Y103.564 G1 Z3.600 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X129.298 Y103.564 E0.00097 G1 X129.298 Y96.328 E0.24492 G1 X129.327 Y96.328 E0.00097 G1 X129.327 Y103.504 E0.24289 M204 S1000 G1 X129.734 Y103.971 F10800.000 M204 S800 G1 F900 G1 X128.891 Y103.971 E0.02853 G1 X128.891 Y95.921 E0.27248 G1 X129.734 Y95.921 E0.02853 G1 X129.734 Y103.911 E0.27045 M204 S1000 G1 X129.381 Y103.783 F10800.000 G1 F8640.000 G1 X128.891 Y103.971 E-0.19510 G1 X128.891 Y101.525 E-0.56490 G1 E-0.04000 F2100.00000 G1 Z4.200 F10800.000 G1 X120.620 Y103.564 G1 Z3.600 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X120.591 Y103.564 E0.00097 G1 X120.591 Y96.328 E0.24492 G1 X120.620 Y96.328 E0.00097 G1 X120.620 Y103.504 E0.24289 M204 S1000 G1 X121.027 Y103.971 F10800.000 M204 S800 G1 F900 G1 X120.184 Y103.971 E0.02853 G1 X120.184 Y95.921 E0.27248 G1 X121.027 Y95.921 E0.02853 G1 X121.027 Y103.911 E0.27045 M204 S1000 G1 X120.673 Y103.783 F10800.000 ;BEFORE_LAYER_CHANGE G92 E0.0 ;3.8 G1 F8640.000 G1 X120.184 Y103.971 E-0.19510 G1 X120.184 Y101.525 E-0.56490 G1 E-0.04000 F2100.00000 G1 Z4.200 F10800.000 ;AFTER_LAYER_CHANGE ;3.8 G1 X148.972 Y103.942 G1 Z3.800 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X148.972 Y95.892 E0.27248 G1 X149.741 Y95.892 E0.02602 G1 X149.741 Y103.942 E0.27248 G1 X149.032 Y103.942 E0.02399 M204 S1000 G1 X148.985 Y103.543 F10800.000 G1 F8640.000 G1 X149.008 Y100.651 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z4.400 F10800.000 G1 X149.357 Y96.096 G1 Z3.800 G1 E0.80000 F2100.00000 G1 F900 G1 X149.357 Y103.739 E0.22987 G1 F8640.000 G1 X149.357 Y100.447 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z4.400 F10800.000 G1 X140.960 Y103.942 G1 Z3.800 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X140.191 Y103.942 E0.02602 G1 X140.191 Y95.892 E0.27248 G1 X140.960 Y95.892 E0.02602 G1 X140.960 Y103.882 E0.27045 M204 S1000 G1 X140.607 Y103.753 F10800.000 G1 F8640.000 G1 X140.191 Y103.942 E-0.17805 G1 X140.191 Y101.422 E-0.58195 G1 E-0.04000 F2100.00000 G1 Z4.400 F10800.000 G1 X140.575 Y96.096 G1 Z3.800 G1 E0.80000 F2100.00000 G1 F900 G1 X140.575 Y103.739 E0.22987 G1 F8640.000 G1 X140.575 Y100.447 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z4.400 F10800.000 G1 X129.734 Y103.971 G1 Z3.800 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X128.965 Y103.971 E0.02602 G1 X128.965 Y95.921 E0.27248 G1 X129.734 Y95.921 E0.02602 G1 X129.734 Y103.911 E0.27045 M204 S1000 G1 X129.381 Y103.782 F10800.000 G1 F8640.000 G1 X128.965 Y103.971 E-0.17806 G1 X128.965 Y101.451 E-0.58194 G1 E-0.04000 F2100.00000 G1 Z4.400 F10800.000 G1 X129.349 Y96.125 G1 Z3.800 G1 E0.80000 F2100.00000 G1 F900 G1 X129.349 Y103.768 E0.22987 G1 F8640.000 G1 X129.349 Y100.476 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z4.400 F10800.000 G1 X120.953 Y103.971 G1 Z3.800 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X120.184 Y103.971 E0.02602 G1 X120.184 Y95.921 E0.27248 G1 X120.953 Y95.921 E0.02602 G1 X120.953 Y103.911 E0.27045 M204 S1000 G1 X120.600 Y103.782 F10800.000 G1 F8640.000 G1 X120.184 Y103.971 E-0.17805 G1 X120.184 Y101.451 E-0.58195 G1 E-0.04000 F2100.00000 G1 Z4.400 F10800.000 G1 X120.568 Y96.125 G1 Z3.800 G1 E0.80000 F2100.00000 G1 F900 G1 X120.568 Y103.768 E0.22987 ;BEFORE_LAYER_CHANGE G92 E0.0 ;4 G1 F8640.000 G1 X120.568 Y100.476 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z4.400 F10800.000 ;AFTER_LAYER_CHANGE ;4 G1 X149.035 Y103.942 G1 Z4.000 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X149.035 Y95.892 E0.27248 G1 X149.741 Y95.892 E0.02391 G1 X149.741 Y103.942 E0.27248 G1 X149.095 Y103.942 E0.02187 M204 S1000 G1 X149.046 Y103.543 F10800.000 G1 F8640.000 G1 X149.070 Y100.651 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z4.600 F10800.000 G1 X149.388 Y96.096 G1 Z4.000 G1 E0.80000 F2100.00000 G1 F900 G1 X149.388 Y103.739 E0.19012 G1 F8640.000 G1 X149.388 Y100.447 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z4.600 F10800.000 G1 X140.897 Y103.942 G1 Z4.000 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X140.191 Y103.942 E0.02391 G1 X140.191 Y95.892 E0.27248 G1 X140.897 Y95.892 E0.02391 G1 X140.897 Y103.882 E0.27045 M204 S1000 G1 X140.545 Y103.753 F10800.000 G1 F8640.000 G1 X140.191 Y103.942 E-0.16366 G1 X140.191 Y101.360 E-0.59634 G1 E-0.04000 F2100.00000 G1 Z4.600 F10800.000 G1 X140.544 Y96.096 G1 Z4.000 G1 E0.80000 F2100.00000 M73 Q27 S16 G1 F900 G1 X140.544 Y103.739 E0.19012 G1 F8640.000 G1 X140.544 Y100.447 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z4.600 F10800.000 G1 X129.734 Y103.971 G1 Z4.000 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X129.028 Y103.971 E0.02391 G1 X129.028 Y95.921 E0.27248 M73 P27 R16 G1 X129.734 Y95.921 E0.02391 G1 X129.734 Y103.911 E0.27045 M204 S1000 G1 X129.382 Y103.781 F10800.000 G1 F8640.000 G1 X129.028 Y103.971 E-0.16366 G1 X129.028 Y101.388 E-0.59634 G1 E-0.04000 F2100.00000 G1 Z4.600 F10800.000 G1 X129.381 Y96.125 G1 Z4.000 G1 E0.80000 F2100.00000 G1 F900 G1 X129.381 Y103.768 E0.19012 G1 F8640.000 G1 X129.381 Y100.476 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z4.600 F10800.000 G1 X120.890 Y103.971 G1 Z4.000 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X120.184 Y103.971 E0.02391 G1 X120.184 Y95.921 E0.27248 G1 X120.890 Y95.921 E0.02391 G1 X120.890 Y103.911 E0.27045 M204 S1000 G1 X120.538 Y103.781 F10800.000 G1 F8640.000 G1 X120.184 Y103.971 E-0.16366 G1 X120.184 Y101.388 E-0.59634 G1 E-0.04000 F2100.00000 G1 Z4.600 F10800.000 G1 X120.537 Y96.125 G1 Z4.000 G1 E0.80000 F2100.00000 G1 F900 G1 X120.537 Y103.768 E0.19012 ;BEFORE_LAYER_CHANGE G92 E0.0 ;4.2 G1 F8640.000 G1 X120.537 Y100.476 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z4.600 F10800.000 ;AFTER_LAYER_CHANGE ;4.2 G1 X149.086 Y103.942 G1 Z4.200 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X149.086 Y95.892 E0.27248 G1 X149.741 Y95.892 E0.02215 G1 X149.741 Y103.942 E0.27248 G1 X149.146 Y103.942 E0.02012 M204 S1000 G1 X149.097 Y103.543 F10800.000 G1 F8640.000 G1 X149.122 Y100.651 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z4.800 F10800.000 G1 X149.414 Y96.096 G1 Z4.200 G1 E0.80000 F2100.00000 G1 F900 G1 X149.414 Y103.739 E0.15723 G1 F8640.000 G1 X149.414 Y100.447 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z4.800 F10800.000 G1 X140.845 Y103.942 G1 Z4.200 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X140.191 Y103.942 E0.02215 G1 X140.191 Y95.892 E0.27248 G1 X140.845 Y95.892 E0.02215 G1 X140.845 Y103.882 E0.27045 M204 S1000 G1 X140.494 Y103.752 F10800.000 G1 F8640.000 G1 X140.191 Y103.942 E-0.15176 G1 X140.191 Y101.308 E-0.60824 G1 E-0.04000 F2100.00000 G1 Z4.800 F10800.000 G1 X140.518 Y96.096 G1 Z4.200 G1 E0.80000 F2100.00000 G1 F900 G1 X140.518 Y103.739 E0.15723 G1 F8640.000 G1 X140.518 Y100.447 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z4.800 F10800.000 G1 X129.734 Y103.971 G1 Z4.200 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X129.079 Y103.971 E0.02215 G1 X129.079 Y95.921 E0.27248 G1 X129.734 Y95.921 E0.02215 G1 X129.734 Y103.911 E0.27045 M204 S1000 G1 X129.382 Y103.780 F10800.000 G1 F8640.000 G1 X129.079 Y103.971 E-0.15176 G1 X129.079 Y101.337 E-0.60824 G1 E-0.04000 F2100.00000 G1 Z4.800 F10800.000 G1 X129.407 Y96.125 G1 Z4.200 G1 E0.80000 F2100.00000 G1 F900 G1 X129.407 Y103.768 E0.15723 G1 F8640.000 G1 X129.407 Y100.476 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z4.800 F10800.000 G1 X120.838 Y103.971 G1 Z4.200 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X120.184 Y103.971 E0.02215 G1 X120.184 Y95.921 E0.27248 G1 X120.838 Y95.921 E0.02215 G1 X120.838 Y103.911 E0.27045 M204 S1000 G1 X120.487 Y103.780 F10800.000 G1 F8640.000 G1 X120.184 Y103.971 E-0.15176 G1 X120.184 Y101.337 E-0.60824 G1 E-0.04000 F2100.00000 G1 Z4.800 F10800.000 G1 X120.511 Y96.125 G1 Z4.200 G1 E0.80000 F2100.00000 G1 F900 G1 X120.511 Y103.768 E0.15723 ;BEFORE_LAYER_CHANGE G92 E0.0 ;4.4 G1 F8640.000 G1 X120.511 Y100.476 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z4.800 F10800.000 ;AFTER_LAYER_CHANGE ;4.4 G1 X149.741 Y103.942 G1 Z4.400 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X149.128 Y103.942 E0.02075 G1 X149.128 Y95.892 E0.27248 G1 X149.741 Y95.892 E0.02075 G1 X149.741 Y103.882 E0.27045 M204 S1000 G1 X149.390 Y103.751 F10800.000 G1 F8640.000 G1 X149.128 Y103.942 E-0.14222 G1 X149.128 Y101.267 E-0.61778 G1 E-0.04000 F2100.00000 G1 Z5.000 F10800.000 G1 X149.434 Y96.096 G1 Z4.400 G1 E0.80000 F2100.00000 G1 F900 G1 X149.434 Y103.739 E0.13087 G1 F8640.000 G1 X149.434 Y100.447 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z5.000 F10800.000 G1 X140.804 Y103.942 G1 Z4.400 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X140.191 Y103.942 E0.02075 G1 X140.191 Y95.892 E0.27248 G1 X140.804 Y95.892 E0.02075 G1 X140.804 Y103.882 E0.27045 M204 S1000 G1 X140.453 Y103.751 F10800.000 G1 F8640.000 G1 X140.191 Y103.942 E-0.14222 G1 X140.191 Y101.267 E-0.61778 G1 E-0.04000 F2100.00000 G1 Z5.000 F10800.000 G1 X140.497 Y96.096 G1 Z4.400 G1 E0.80000 F2100.00000 G1 F900 G1 X140.497 Y103.739 E0.13087 G1 F8640.000 G1 X140.497 Y100.447 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z5.000 F10800.000 G1 X129.734 Y103.971 G1 Z4.400 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X129.121 Y103.971 E0.02075 G1 X129.121 Y95.921 E0.27248 G1 X129.734 Y95.921 E0.02075 G1 X129.734 Y103.911 E0.27045 M204 S1000 G1 X129.382 Y103.780 F10800.000 G1 F8640.000 G1 X129.121 Y103.971 E-0.14222 G1 X129.121 Y101.296 E-0.61778 G1 E-0.04000 F2100.00000 G1 Z5.000 F10800.000 G1 X129.427 Y96.125 G1 Z4.400 G1 E0.80000 F2100.00000 G1 F900 G1 X129.427 Y103.768 E0.13087 G1 F8640.000 G1 X129.427 Y100.476 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z5.000 F10800.000 G1 X120.797 Y103.971 G1 Z4.400 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X120.184 Y103.971 E0.02075 G1 X120.184 Y95.921 E0.27248 G1 X120.797 Y95.921 E0.02075 G1 X120.797 Y103.911 E0.27045 M204 S1000 G1 X120.445 Y103.780 F10800.000 G1 F8640.000 G1 X120.184 Y103.971 E-0.14222 G1 X120.184 Y101.296 E-0.61778 G1 E-0.04000 F2100.00000 G1 Z5.000 F10800.000 G1 X120.490 Y96.125 G1 Z4.400 G1 E0.80000 F2100.00000 G1 F900 G1 X120.490 Y103.768 E0.13087 ;BEFORE_LAYER_CHANGE G92 E0.0 ;4.6 G1 F8640.000 G1 X120.490 Y100.476 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z5.000 F10800.000 ;AFTER_LAYER_CHANGE ;4.6 G1 X149.741 Y103.942 G1 Z4.600 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X149.160 Y103.942 E0.01968 G1 X149.160 Y95.892 E0.27248 G1 X149.741 Y95.892 E0.01968 G1 X149.741 Y103.882 E0.27045 M204 S1000 G1 X149.390 Y103.751 F10800.000 G1 F8640.000 G1 X149.160 Y103.942 E-0.13496 G1 X149.160 Y101.235 E-0.62504 G1 E-0.04000 F2100.00000 G1 Z5.200 F10800.000 G1 X149.450 Y96.096 G1 Z4.600 G1 E0.80000 F2100.00000 G1 F900 G1 X149.450 Y103.739 E0.11079 G1 F8640.000 G1 X149.450 Y100.447 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z5.200 F10800.000 G1 X140.772 Y103.942 G1 Z4.600 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X140.191 Y103.942 E0.01968 G1 X140.191 Y95.892 E0.27248 G1 X140.772 Y95.892 E0.01968 G1 X140.772 Y103.882 E0.27045 M204 S1000 G1 X140.421 Y103.751 F10800.000 G1 F8640.000 G1 X140.191 Y103.942 E-0.13496 G1 X140.191 Y101.235 E-0.62504 G1 E-0.04000 F2100.00000 G1 Z5.200 F10800.000 G1 X140.482 Y96.096 G1 Z4.600 G1 E0.80000 F2100.00000 G1 F900 G1 X140.482 Y103.739 E0.11079 G1 F8640.000 G1 X140.482 Y100.447 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z5.200 F10800.000 G1 X129.734 Y103.971 G1 Z4.600 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X129.152 Y103.971 E0.01968 G1 X129.152 Y95.921 E0.27248 G1 X129.734 Y95.921 E0.01968 G1 X129.734 Y103.911 E0.27045 M204 S1000 G1 X129.383 Y103.779 F10800.000 G1 F8640.000 G1 X129.152 Y103.971 E-0.13496 G1 X129.152 Y101.264 E-0.62504 G1 E-0.04000 F2100.00000 G1 Z5.200 F10800.000 G1 X129.443 Y96.125 G1 Z4.600 G1 E0.80000 F2100.00000 G1 F900 G1 X129.443 Y103.768 E0.11079 G1 F8640.000 G1 X129.443 Y100.476 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z5.200 F10800.000 G1 X120.765 Y103.971 G1 Z4.600 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X120.184 Y103.971 E0.01968 G1 X120.184 Y95.921 E0.27248 G1 X120.765 Y95.921 E0.01968 G1 X120.765 Y103.911 E0.27045 M204 S1000 G1 X120.414 Y103.779 F10800.000 G1 F8640.000 G1 X120.184 Y103.971 E-0.13496 G1 X120.184 Y101.264 E-0.62504 G1 E-0.04000 F2100.00000 G1 Z5.200 F10800.000 G1 X120.475 Y96.125 G1 Z4.600 G1 E0.80000 F2100.00000 G1 F900 G1 X120.475 Y103.768 E0.11079 ;BEFORE_LAYER_CHANGE G92 E0.0 ;4.8 G1 F8640.000 G1 X120.475 Y100.476 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z5.200 F10800.000 ;AFTER_LAYER_CHANGE ;4.8 G1 X149.741 Y103.942 G1 Z4.800 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X149.178 Y103.942 E0.01904 G1 X149.178 Y95.892 E0.27248 G1 X149.741 Y95.892 E0.01904 G1 X149.741 Y103.882 E0.27045 M204 S1000 G1 X149.390 Y103.750 F10800.000 G1 F8640.000 G1 X149.178 Y103.942 E-0.13062 G1 X149.178 Y101.217 E-0.62938 G1 E-0.04000 F2100.00000 G1 Z5.400 F10800.000 G1 X149.460 Y96.096 G1 Z4.800 G1 E0.80000 F2100.00000 G1 F900 G1 X149.460 Y103.739 E0.09878 G1 F8640.000 G1 X149.460 Y100.447 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z5.400 F10800.000 G1 X140.753 Y103.942 G1 Z4.800 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X140.191 Y103.942 E0.01904 G1 X140.191 Y95.892 E0.27248 G1 X140.753 Y95.892 E0.01904 G1 X140.753 Y103.882 E0.27045 M204 S1000 G1 X140.403 Y103.750 F10800.000 G1 F8640.000 G1 X140.191 Y103.942 E-0.13062 G1 X140.191 Y101.217 E-0.62938 G1 E-0.04000 F2100.00000 G1 Z5.400 F10800.000 G1 X140.472 Y96.096 G1 Z4.800 G1 E0.80000 F2100.00000 G1 F900 G1 X140.472 Y103.739 E0.09878 G1 F8640.000 G1 X140.472 Y100.447 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z5.400 F10800.000 G1 X129.734 Y103.971 G1 Z4.800 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X129.171 Y103.971 E0.01904 G1 X129.171 Y95.921 E0.27248 G1 X129.734 Y95.921 E0.01904 G1 X129.734 Y103.911 E0.27045 M204 S1000 G1 X129.383 Y103.779 F10800.000 G1 F8640.000 G1 X129.171 Y103.971 E-0.13062 G1 X129.171 Y101.245 E-0.62938 G1 E-0.04000 F2100.00000 G1 Z5.400 F10800.000 G1 X129.453 Y96.125 G1 Z4.800 G1 E0.80000 F2100.00000 G1 F900 G1 X129.453 Y103.768 E0.09878 G1 F8640.000 G1 X129.453 Y100.476 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z5.400 F10800.000 G1 X120.746 Y103.971 G1 Z4.800 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X120.184 Y103.971 E0.01904 G1 X120.184 Y95.921 E0.27248 G1 X120.746 Y95.921 E0.01904 G1 X120.746 Y103.911 E0.27045 M204 S1000 G1 X120.395 Y103.779 F10800.000 G1 F8640.000 G1 X120.184 Y103.971 E-0.13062 G1 X120.184 Y101.245 E-0.62938 G1 E-0.04000 F2100.00000 G1 Z5.400 F10800.000 G1 X120.465 Y96.125 G1 Z4.800 G1 E0.80000 F2100.00000 G1 F900 G1 X120.465 Y103.768 E0.09878 ;BEFORE_LAYER_CHANGE G92 E0.0 ;5 G1 F8640.000 G1 X120.465 Y100.476 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z5.400 F10800.000 ;AFTER_LAYER_CHANGE ;5 G1 X149.741 Y103.942 G1 Z5.000 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X149.188 Y103.942 E0.01872 G1 X149.188 Y95.892 E0.27248 G1 X149.741 Y95.892 E0.01872 G1 X149.741 Y103.882 E0.27045 M204 S1000 G1 X149.390 Y103.750 F10800.000 G1 F8640.000 G1 X149.188 Y103.942 E-0.12847 G1 X149.188 Y101.207 E-0.63153 G1 E-0.04000 F2100.00000 G1 Z5.600 F10800.000 G1 X149.464 Y96.096 G1 Z5.000 G1 E0.80000 F2100.00000 G1 F900 G1 X149.464 Y103.739 E0.09283 G1 F8640.000 G1 X149.464 Y100.447 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z5.600 F10800.000 G1 X140.744 Y103.942 G1 Z5.000 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X140.191 Y103.942 E0.01872 G1 X140.191 Y95.892 E0.27248 G1 X140.744 Y95.892 E0.01872 G1 X140.744 Y103.882 E0.27045 M204 S1000 G1 X140.393 Y103.750 F10800.000 G1 F8640.000 G1 X140.191 Y103.942 E-0.12847 G1 X140.191 Y101.207 E-0.63153 G1 E-0.04000 F2100.00000 G1 Z5.600 F10800.000 G1 X140.468 Y96.096 G1 Z5.000 G1 E0.80000 F2100.00000 G1 F900 G1 X140.468 Y103.739 E0.09283 G1 F8640.000 G1 X140.468 Y100.447 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z5.600 F10800.000 G1 X129.734 Y103.971 G1 Z5.000 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X129.181 Y103.971 E0.01872 G1 X129.181 Y95.921 E0.27248 G1 X129.734 Y95.921 E0.01872 G1 X129.734 Y103.911 E0.27045 M204 S1000 G1 X129.383 Y103.779 F10800.000 G1 F8640.000 G1 X129.181 Y103.971 E-0.12847 G1 X129.181 Y101.236 E-0.63153 G1 E-0.04000 F2100.00000 G1 Z5.600 F10800.000 G1 X129.457 Y96.125 G1 Z5.000 G1 E0.80000 F2100.00000 G1 F900 G1 X129.457 Y103.768 E0.09283 G1 F8640.000 G1 X129.457 Y100.476 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z5.600 F10800.000 G1 X120.737 Y103.971 G1 Z5.000 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X120.184 Y103.971 E0.01872 G1 X120.184 Y95.921 E0.27248 G1 X120.737 Y95.921 E0.01872 G1 X120.737 Y103.911 E0.27045 M204 S1000 G1 X120.386 Y103.779 F10800.000 G1 F8640.000 G1 X120.184 Y103.971 E-0.12847 G1 X120.184 Y101.236 E-0.63153 G1 E-0.04000 F2100.00000 G1 Z5.600 F10800.000 G1 X120.460 Y96.125 G1 Z5.000 G1 E0.80000 F2100.00000 G1 F900 G1 X120.460 Y103.768 E0.09283 ;BEFORE_LAYER_CHANGE G92 E0.0 ;5.2 G1 F8640.000 G1 X120.460 Y100.476 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z5.600 F10800.000 ;AFTER_LAYER_CHANGE ;5.2 G1 X149.741 Y103.942 G1 Z5.200 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X149.188 Y103.942 E0.01872 G1 X149.188 Y95.892 E0.27248 G1 X149.741 Y95.892 E0.01872 G1 X149.741 Y103.882 E0.27045 M73 Q32 S15 M204 S1000 G1 X149.390 Y103.750 F10800.000 G1 F8640.000 G1 X149.188 Y103.942 E-0.12847 G1 X149.188 Y101.207 E-0.63153 G1 E-0.04000 F2100.00000 G1 Z5.800 F10800.000 G1 X149.464 Y96.096 G1 Z5.200 G1 E0.80000 F2100.00000 G1 F900 G1 X149.464 Y103.739 E0.09283 G1 F8640.000 G1 X149.464 Y100.447 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z5.800 F10800.000 G1 X140.744 Y103.942 G1 Z5.200 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X140.191 Y103.942 E0.01872 G1 X140.191 Y95.892 E0.27248 M73 P32 R15 G1 X140.744 Y95.892 E0.01872 G1 X140.744 Y103.882 E0.27045 M204 S1000 G1 X140.393 Y103.750 F10800.000 G1 F8640.000 G1 X140.191 Y103.942 E-0.12847 G1 X140.191 Y101.207 E-0.63153 G1 E-0.04000 F2100.00000 G1 Z5.800 F10800.000 G1 X140.468 Y96.096 G1 Z5.200 G1 E0.80000 F2100.00000 G1 F900 G1 X140.468 Y103.739 E0.09283 G1 F8640.000 G1 X140.468 Y100.447 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z5.800 F10800.000 G1 X129.734 Y103.971 G1 Z5.200 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X129.181 Y103.971 E0.01872 G1 X129.181 Y95.921 E0.27248 G1 X129.734 Y95.921 E0.01872 G1 X129.734 Y103.911 E0.27045 M204 S1000 G1 X129.383 Y103.779 F10800.000 G1 F8640.000 G1 X129.181 Y103.971 E-0.12847 G1 X129.181 Y101.236 E-0.63153 G1 E-0.04000 F2100.00000 G1 Z5.800 F10800.000 G1 X129.457 Y96.125 G1 Z5.200 G1 E0.80000 F2100.00000 G1 F900 G1 X129.457 Y103.768 E0.09283 G1 F8640.000 G1 X129.457 Y100.476 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z5.800 F10800.000 G1 X120.737 Y103.971 G1 Z5.200 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X120.184 Y103.971 E0.01872 G1 X120.184 Y95.921 E0.27248 G1 X120.737 Y95.921 E0.01872 G1 X120.737 Y103.911 E0.27045 M204 S1000 G1 X120.386 Y103.779 F10800.000 G1 F8640.000 G1 X120.184 Y103.971 E-0.12847 G1 X120.184 Y101.236 E-0.63153 G1 E-0.04000 F2100.00000 G1 Z5.800 F10800.000 G1 X120.460 Y96.125 G1 Z5.200 G1 E0.80000 F2100.00000 G1 F900 G1 X120.460 Y103.768 E0.09283 ;BEFORE_LAYER_CHANGE G92 E0.0 ;5.4 G1 F8640.000 G1 X120.460 Y100.476 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z5.800 F10800.000 ;AFTER_LAYER_CHANGE ;5.4 G1 X149.741 Y103.942 G1 Z5.400 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X149.178 Y103.942 E0.01904 G1 X149.178 Y95.892 E0.27248 G1 X149.741 Y95.892 E0.01904 G1 X149.741 Y103.882 E0.27045 M204 S1000 G1 X149.390 Y103.750 F10800.000 G1 F8640.000 G1 X149.178 Y103.942 E-0.13062 G1 X149.178 Y101.217 E-0.62938 G1 E-0.04000 F2100.00000 G1 Z6.000 F10800.000 G1 X149.460 Y96.096 G1 Z5.400 G1 E0.80000 F2100.00000 G1 F900 G1 X149.460 Y103.739 E0.09878 G1 F8640.000 G1 X149.460 Y100.447 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z6.000 F10800.000 G1 X140.753 Y103.942 G1 Z5.400 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X140.191 Y103.942 E0.01904 G1 X140.191 Y95.892 E0.27248 G1 X140.753 Y95.892 E0.01904 G1 X140.753 Y103.882 E0.27045 M204 S1000 G1 X140.403 Y103.750 F10800.000 G1 F8640.000 G1 X140.191 Y103.942 E-0.13062 G1 X140.191 Y101.217 E-0.62938 G1 E-0.04000 F2100.00000 G1 Z6.000 F10800.000 G1 X140.472 Y96.096 G1 Z5.400 G1 E0.80000 F2100.00000 G1 F900 G1 X140.472 Y103.739 E0.09878 G1 F8640.000 G1 X140.472 Y100.447 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z6.000 F10800.000 G1 X129.734 Y103.971 G1 Z5.400 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X129.171 Y103.971 E0.01904 G1 X129.171 Y95.921 E0.27248 G1 X129.734 Y95.921 E0.01904 G1 X129.734 Y103.911 E0.27045 M204 S1000 G1 X129.383 Y103.779 F10800.000 G1 F8640.000 G1 X129.171 Y103.971 E-0.13062 G1 X129.171 Y101.245 E-0.62938 G1 E-0.04000 F2100.00000 G1 Z6.000 F10800.000 G1 X129.453 Y96.125 G1 Z5.400 G1 E0.80000 F2100.00000 G1 F900 G1 X129.453 Y103.768 E0.09878 G1 F8640.000 G1 X129.453 Y100.476 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z6.000 F10800.000 G1 X120.746 Y103.971 G1 Z5.400 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X120.184 Y103.971 E0.01904 G1 X120.184 Y95.921 E0.27248 G1 X120.746 Y95.921 E0.01904 G1 X120.746 Y103.911 E0.27045 M204 S1000 G1 X120.395 Y103.779 F10800.000 G1 F8640.000 G1 X120.184 Y103.971 E-0.13062 G1 X120.184 Y101.245 E-0.62938 G1 E-0.04000 F2100.00000 G1 Z6.000 F10800.000 G1 X120.465 Y96.125 G1 Z5.400 G1 E0.80000 F2100.00000 G1 F900 G1 X120.465 Y103.768 E0.09878 ;BEFORE_LAYER_CHANGE G92 E0.0 ;5.6 G1 F8640.000 G1 X120.465 Y100.476 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z6.000 F10800.000 ;AFTER_LAYER_CHANGE ;5.6 G1 X149.741 Y103.942 G1 Z5.600 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X149.160 Y103.942 E0.01968 G1 X149.160 Y95.892 E0.27248 G1 X149.741 Y95.892 E0.01968 G1 X149.741 Y103.882 E0.27045 M204 S1000 G1 X149.390 Y103.751 F10800.000 G1 F8640.000 G1 X149.160 Y103.942 E-0.13496 G1 X149.160 Y101.235 E-0.62504 G1 E-0.04000 F2100.00000 G1 Z6.200 F10800.000 G1 X149.450 Y96.096 G1 Z5.600 G1 E0.80000 F2100.00000 G1 F900 G1 X149.450 Y103.739 E0.11079 G1 F8640.000 G1 X149.450 Y100.447 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z6.200 F10800.000 G1 X140.772 Y103.942 G1 Z5.600 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X140.191 Y103.942 E0.01968 G1 X140.191 Y95.892 E0.27248 G1 X140.772 Y95.892 E0.01968 G1 X140.772 Y103.882 E0.27045 M204 S1000 G1 X140.421 Y103.751 F10800.000 G1 F8640.000 G1 X140.191 Y103.942 E-0.13496 G1 X140.191 Y101.235 E-0.62504 G1 E-0.04000 F2100.00000 G1 Z6.200 F10800.000 G1 X140.482 Y96.096 G1 Z5.600 G1 E0.80000 F2100.00000 G1 F900 G1 X140.482 Y103.739 E0.11079 G1 F8640.000 G1 X140.482 Y100.447 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z6.200 F10800.000 G1 X129.734 Y103.971 G1 Z5.600 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X129.152 Y103.971 E0.01968 G1 X129.152 Y95.921 E0.27248 G1 X129.734 Y95.921 E0.01968 G1 X129.734 Y103.911 E0.27045 M204 S1000 G1 X129.383 Y103.779 F10800.000 G1 F8640.000 G1 X129.152 Y103.971 E-0.13496 G1 X129.152 Y101.264 E-0.62504 G1 E-0.04000 F2100.00000 G1 Z6.200 F10800.000 G1 X129.443 Y96.125 G1 Z5.600 G1 E0.80000 F2100.00000 G1 F900 G1 X129.443 Y103.768 E0.11079 G1 F8640.000 G1 X129.443 Y100.476 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z6.200 F10800.000 G1 X120.765 Y103.971 G1 Z5.600 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X120.184 Y103.971 E0.01968 G1 X120.184 Y95.921 E0.27248 G1 X120.765 Y95.921 E0.01968 G1 X120.765 Y103.911 E0.27045 M204 S1000 G1 X120.414 Y103.779 F10800.000 G1 F8640.000 G1 X120.184 Y103.971 E-0.13496 G1 X120.184 Y101.264 E-0.62504 G1 E-0.04000 F2100.00000 G1 Z6.200 F10800.000 G1 X120.475 Y96.125 G1 Z5.600 G1 E0.80000 F2100.00000 G1 F900 G1 X120.475 Y103.768 E0.11079 ;BEFORE_LAYER_CHANGE G92 E0.0 ;5.8 G1 F8640.000 G1 X120.475 Y100.476 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z6.200 F10800.000 ;AFTER_LAYER_CHANGE ;5.8 G1 X149.741 Y103.942 G1 Z5.800 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X149.128 Y103.942 E0.02075 G1 X149.128 Y95.892 E0.27248 G1 X149.741 Y95.892 E0.02075 G1 X149.741 Y103.882 E0.27045 M204 S1000 G1 X149.390 Y103.751 F10800.000 G1 F8640.000 G1 X149.128 Y103.942 E-0.14222 G1 X149.128 Y101.267 E-0.61778 G1 E-0.04000 F2100.00000 G1 Z6.400 F10800.000 G1 X149.434 Y96.096 G1 Z5.800 G1 E0.80000 F2100.00000 G1 F900 G1 X149.434 Y103.739 E0.13087 G1 F8640.000 G1 X149.434 Y100.447 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z6.400 F10800.000 G1 X140.804 Y103.942 G1 Z5.800 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X140.191 Y103.942 E0.02075 G1 X140.191 Y95.892 E0.27248 G1 X140.804 Y95.892 E0.02075 G1 X140.804 Y103.882 E0.27045 M204 S1000 G1 X140.453 Y103.751 F10800.000 G1 F8640.000 G1 X140.191 Y103.942 E-0.14222 G1 X140.191 Y101.267 E-0.61778 G1 E-0.04000 F2100.00000 G1 Z6.400 F10800.000 G1 X140.497 Y96.096 G1 Z5.800 G1 E0.80000 F2100.00000 G1 F900 G1 X140.497 Y103.739 E0.13087 G1 F8640.000 G1 X140.497 Y100.447 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z6.400 F10800.000 G1 X129.734 Y103.971 G1 Z5.800 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X129.121 Y103.971 E0.02075 G1 X129.121 Y95.921 E0.27248 G1 X129.734 Y95.921 E0.02075 G1 X129.734 Y103.911 E0.27045 M204 S1000 G1 X129.382 Y103.780 F10800.000 G1 F8640.000 G1 X129.121 Y103.971 E-0.14222 G1 X129.121 Y101.296 E-0.61778 G1 E-0.04000 F2100.00000 G1 Z6.400 F10800.000 G1 X129.427 Y96.125 G1 Z5.800 G1 E0.80000 F2100.00000 G1 F900 G1 X129.427 Y103.768 E0.13087 G1 F8640.000 G1 X129.427 Y100.476 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z6.400 F10800.000 G1 X120.797 Y103.971 G1 Z5.800 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X120.184 Y103.971 E0.02075 G1 X120.184 Y95.921 E0.27248 G1 X120.797 Y95.921 E0.02075 G1 X120.797 Y103.911 E0.27045 M204 S1000 G1 X120.445 Y103.780 F10800.000 G1 F8640.000 G1 X120.184 Y103.971 E-0.14222 G1 X120.184 Y101.296 E-0.61778 G1 E-0.04000 F2100.00000 G1 Z6.400 F10800.000 G1 X120.490 Y96.125 G1 Z5.800 G1 E0.80000 F2100.00000 G1 F900 G1 X120.490 Y103.768 E0.13087 ;BEFORE_LAYER_CHANGE G92 E0.0 ;6 G1 F8640.000 G1 X120.490 Y100.476 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z6.400 F10800.000 ;AFTER_LAYER_CHANGE ;6 G1 X149.741 Y103.942 G1 Z6.000 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X149.086 Y103.942 E0.02215 G1 X149.086 Y95.892 E0.27248 G1 X149.741 Y95.892 E0.02215 G1 X149.741 Y103.882 E0.27045 M204 S1000 G1 X149.389 Y103.752 F10800.000 G1 F8640.000 G1 X149.086 Y103.942 E-0.15176 G1 X149.086 Y101.308 E-0.60824 G1 E-0.04000 F2100.00000 G1 Z6.600 F10800.000 G1 X149.414 Y96.096 G1 Z6.000 G1 E0.80000 F2100.00000 G1 F900 G1 X149.414 Y103.739 E0.15723 G1 F8640.000 G1 X149.414 Y100.447 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z6.600 F10800.000 G1 X140.845 Y103.942 G1 Z6.000 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X140.191 Y103.942 E0.02215 G1 X140.191 Y95.892 E0.27248 G1 X140.845 Y95.892 E0.02215 G1 X140.845 Y103.882 E0.27045 M204 S1000 G1 X140.494 Y103.752 F10800.000 G1 F8640.000 G1 X140.191 Y103.942 E-0.15176 G1 X140.191 Y101.308 E-0.60824 G1 E-0.04000 F2100.00000 G1 Z6.600 F10800.000 G1 X140.518 Y96.096 G1 Z6.000 G1 E0.80000 F2100.00000 G1 F900 G1 X140.518 Y103.739 E0.15723 G1 F8640.000 G1 X140.518 Y100.447 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z6.600 F10800.000 G1 X129.734 Y103.971 G1 Z6.000 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X129.079 Y103.971 E0.02215 G1 X129.079 Y95.921 E0.27248 G1 X129.734 Y95.921 E0.02215 G1 X129.734 Y103.911 E0.27045 M204 S1000 G1 X129.382 Y103.780 F10800.000 G1 F8640.000 G1 X129.079 Y103.971 E-0.15176 G1 X129.079 Y101.337 E-0.60824 G1 E-0.04000 F2100.00000 G1 Z6.600 F10800.000 G1 X129.407 Y96.125 G1 Z6.000 G1 E0.80000 F2100.00000 G1 F900 G1 X129.407 Y103.768 E0.15723 G1 F8640.000 G1 X129.407 Y100.476 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z6.600 F10800.000 G1 X120.838 Y103.971 G1 Z6.000 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X120.184 Y103.971 E0.02215 G1 X120.184 Y95.921 E0.27248 G1 X120.838 Y95.921 E0.02215 G1 X120.838 Y103.911 E0.27045 M204 S1000 G1 X120.487 Y103.780 F10800.000 G1 F8640.000 G1 X120.184 Y103.971 E-0.15176 G1 X120.184 Y101.337 E-0.60824 G1 E-0.04000 F2100.00000 G1 Z6.600 F10800.000 G1 X120.511 Y96.125 G1 Z6.000 G1 E0.80000 F2100.00000 G1 F900 G1 X120.511 Y103.768 E0.15723 ;BEFORE_LAYER_CHANGE G92 E0.0 ;6.2 G1 F8640.000 G1 X120.511 Y100.476 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z6.600 F10800.000 ;AFTER_LAYER_CHANGE ;6.2 G1 X149.741 Y103.942 G1 Z6.200 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X149.035 Y103.942 E0.02391 G1 X149.035 Y95.892 E0.27248 G1 X149.741 Y95.892 E0.02391 G1 X149.741 Y103.882 E0.27045 M204 S1000 G1 X149.389 Y103.753 F10800.000 G1 F8640.000 G1 X149.035 Y103.942 E-0.16366 G1 X149.035 Y101.360 E-0.59634 G1 E-0.04000 F2100.00000 G1 Z6.800 F10800.000 G1 X149.388 Y96.096 G1 Z6.200 G1 E0.80000 F2100.00000 G1 F900 G1 X149.388 Y103.739 E0.19012 G1 F8640.000 G1 X149.388 Y100.447 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z6.800 F10800.000 G1 X140.897 Y103.942 G1 Z6.200 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X140.191 Y103.942 E0.02391 G1 X140.191 Y95.892 E0.27248 G1 X140.897 Y95.892 E0.02391 G1 X140.897 Y103.882 E0.27045 M204 S1000 G1 X140.545 Y103.753 F10800.000 G1 F8640.000 G1 X140.191 Y103.942 E-0.16366 G1 X140.191 Y101.360 E-0.59634 G1 E-0.04000 F2100.00000 G1 Z6.800 F10800.000 G1 X140.544 Y96.096 G1 Z6.200 G1 E0.80000 F2100.00000 G1 F900 G1 X140.544 Y103.739 E0.19012 G1 F8640.000 G1 X140.544 Y100.447 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z6.800 F10800.000 G1 X129.734 Y103.971 G1 Z6.200 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X129.028 Y103.971 E0.02391 G1 X129.028 Y95.921 E0.27248 G1 X129.734 Y95.921 E0.02391 G1 X129.734 Y103.911 E0.27045 M204 S1000 G1 X129.382 Y103.781 F10800.000 G1 F8640.000 G1 X129.028 Y103.971 E-0.16366 G1 X129.028 Y101.388 E-0.59634 G1 E-0.04000 F2100.00000 G1 Z6.800 F10800.000 G1 X129.381 Y96.125 G1 Z6.200 G1 E0.80000 F2100.00000 G1 F900 G1 X129.381 Y103.768 E0.19012 G1 F8640.000 G1 X129.381 Y100.476 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z6.800 F10800.000 G1 X120.890 Y103.971 G1 Z6.200 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X120.184 Y103.971 E0.02391 G1 X120.184 Y95.921 E0.27248 M73 Q36 S14 G1 X120.890 Y95.921 E0.02391 G1 X120.890 Y103.911 E0.27045 M204 S1000 G1 X120.538 Y103.781 F10800.000 G1 F8640.000 G1 X120.184 Y103.971 E-0.16366 G1 X120.184 Y101.388 E-0.59634 G1 E-0.04000 F2100.00000 G1 Z6.800 F10800.000 G1 X120.537 Y96.125 G1 Z6.200 G1 E0.80000 F2100.00000 G1 F900 G1 X120.537 Y103.768 E0.19012 ;BEFORE_LAYER_CHANGE G92 E0.0 ;6.4 G1 F8640.000 G1 X120.537 Y100.476 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z6.800 F10800.000 ;AFTER_LAYER_CHANGE ;6.4 G1 X149.741 Y103.942 G1 Z6.400 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X148.972 Y103.942 E0.02602 G1 X148.972 Y95.892 E0.27248 M73 P36 R14 G1 X149.741 Y95.892 E0.02602 G1 X149.741 Y103.882 E0.27045 M204 S1000 G1 X149.388 Y103.753 F10800.000 G1 F8640.000 G1 X148.972 Y103.942 E-0.17806 G1 X148.972 Y101.422 E-0.58194 G1 E-0.04000 F2100.00000 G1 Z7.000 F10800.000 G1 X149.357 Y96.096 G1 Z6.400 G1 E0.80000 F2100.00000 G1 F900 G1 X149.357 Y103.739 E0.22987 G1 F8640.000 G1 X149.357 Y100.447 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z7.000 F10800.000 G1 X140.960 Y103.942 G1 Z6.400 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X140.191 Y103.942 E0.02602 G1 X140.191 Y95.892 E0.27248 G1 X140.960 Y95.892 E0.02602 G1 X140.960 Y103.882 E0.27045 M204 S1000 G1 X140.607 Y103.753 F10800.000 G1 F8640.000 G1 X140.191 Y103.942 E-0.17805 G1 X140.191 Y101.422 E-0.58195 G1 E-0.04000 F2100.00000 G1 Z7.000 F10800.000 G1 X140.575 Y96.096 G1 Z6.400 G1 E0.80000 F2100.00000 G1 F900 G1 X140.575 Y103.739 E0.22987 G1 F8640.000 G1 X140.575 Y100.447 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z7.000 F10800.000 G1 X129.734 Y103.971 G1 Z6.400 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X128.965 Y103.971 E0.02602 G1 X128.965 Y95.921 E0.27248 G1 X129.734 Y95.921 E0.02602 G1 X129.734 Y103.911 E0.27045 M204 S1000 G1 X129.381 Y103.782 F10800.000 G1 F8640.000 G1 X128.965 Y103.971 E-0.17806 G1 X128.965 Y101.451 E-0.58194 G1 E-0.04000 F2100.00000 G1 Z7.000 F10800.000 G1 X129.349 Y96.125 G1 Z6.400 G1 E0.80000 F2100.00000 G1 F900 G1 X129.349 Y103.768 E0.22987 G1 F8640.000 G1 X129.349 Y100.476 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z7.000 F10800.000 G1 X120.953 Y103.971 G1 Z6.400 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X120.184 Y103.971 E0.02602 G1 X120.184 Y95.921 E0.27248 G1 X120.953 Y95.921 E0.02602 G1 X120.953 Y103.911 E0.27045 M204 S1000 G1 X120.600 Y103.782 F10800.000 G1 F8640.000 G1 X120.184 Y103.971 E-0.17805 G1 X120.184 Y101.451 E-0.58195 G1 E-0.04000 F2100.00000 G1 Z7.000 F10800.000 G1 X120.568 Y96.125 G1 Z6.400 G1 E0.80000 F2100.00000 G1 F900 G1 X120.568 Y103.768 E0.22987 ;BEFORE_LAYER_CHANGE G92 E0.0 ;6.6 G1 F8640.000 G1 X120.568 Y100.476 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z7.000 F10800.000 ;AFTER_LAYER_CHANGE ;6.6 G1 X149.305 Y103.535 G1 Z6.600 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X149.305 Y96.299 E0.24492 G1 X149.334 Y96.299 E0.00097 G1 X149.334 Y103.504 E0.24386 M204 S1000 G1 X149.741 Y103.942 F10800.000 M204 S800 G1 F900 G1 X148.898 Y103.942 E0.02853 G1 X148.898 Y95.892 E0.27248 G1 X149.741 Y95.892 E0.02853 G1 X149.741 Y103.882 E0.27045 M204 S1000 G1 X149.388 Y103.755 F10800.000 G1 F8640.000 G1 X148.898 Y103.942 E-0.19510 G1 X148.898 Y101.496 E-0.56490 G1 E-0.04000 F2100.00000 G1 Z7.200 F10800.000 G1 X140.627 Y103.535 G1 Z6.600 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X140.598 Y103.535 E0.00097 G1 X140.598 Y96.299 E0.24492 G1 X140.627 Y96.299 E0.00097 G1 X140.627 Y103.475 E0.24289 M204 S1000 G1 X141.034 Y103.942 F10800.000 M204 S800 G1 F900 G1 X140.191 Y103.942 E0.02853 G1 X140.191 Y95.892 E0.27248 G1 X141.034 Y95.892 E0.02853 G1 X141.034 Y103.882 E0.27045 M204 S1000 G1 X140.681 Y103.755 F10800.000 G1 F8640.000 G1 X140.191 Y103.942 E-0.19510 G1 X140.191 Y101.496 E-0.56490 G1 E-0.04000 F2100.00000 G1 Z7.200 F10800.000 G1 X129.298 Y103.564 G1 Z6.600 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X129.298 Y96.328 E0.24492 G1 X129.327 Y96.328 E0.00097 G1 X129.327 Y103.533 E0.24386 M204 S1000 G1 X129.734 Y103.971 F10800.000 M204 S800 G1 F900 G1 X128.891 Y103.971 E0.02853 G1 X128.891 Y95.921 E0.27248 G1 X129.734 Y95.921 E0.02853 G1 X129.734 Y103.911 E0.27045 M204 S1000 G1 X129.381 Y103.783 F10800.000 G1 F8640.000 G1 X128.891 Y103.971 E-0.19510 G1 X128.891 Y101.525 E-0.56490 G1 E-0.04000 F2100.00000 G1 Z7.200 F10800.000 G1 X120.620 Y103.564 G1 Z6.600 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X120.591 Y103.564 E0.00097 G1 X120.591 Y96.328 E0.24492 G1 X120.620 Y96.328 E0.00097 G1 X120.620 Y103.504 E0.24289 M204 S1000 G1 X121.027 Y103.971 F10800.000 M204 S800 G1 F900 G1 X120.184 Y103.971 E0.02853 G1 X120.184 Y95.921 E0.27248 G1 X121.027 Y95.921 E0.02853 G1 X121.027 Y103.911 E0.27045 M204 S1000 G1 X120.673 Y103.783 F10800.000 ;BEFORE_LAYER_CHANGE G92 E0.0 ;6.8 G1 F8640.000 G1 X120.184 Y103.971 E-0.19510 G1 X120.184 Y101.525 E-0.56490 G1 E-0.04000 F2100.00000 G1 Z7.200 F10800.000 ;AFTER_LAYER_CHANGE ;6.8 G1 X149.219 Y103.535 G1 Z6.800 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X149.219 Y96.299 E0.24492 G1 X149.334 Y96.299 E0.00390 G1 X149.334 Y103.535 E0.24492 G1 X149.279 Y103.535 E0.00187 M204 S1000 G1 X149.741 Y103.942 F10800.000 M204 S800 G1 F900 G1 X148.812 Y103.942 E0.03146 G1 X148.812 Y95.892 E0.27248 G1 X149.741 Y95.892 E0.03146 G1 X149.741 Y103.882 E0.27045 M204 S1000 G1 X149.387 Y103.756 F10800.000 G1 F8640.000 G1 X148.812 Y103.942 E-0.21503 G1 X148.812 Y101.582 E-0.54497 G1 E-0.04000 F2100.00000 G1 Z7.400 F10800.000 G1 X140.713 Y103.535 G1 Z6.800 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X140.598 Y103.535 E0.00390 G1 X140.598 Y96.299 E0.24492 G1 X140.713 Y96.299 E0.00390 G1 X140.713 Y103.475 E0.24289 M204 S1000 G1 X141.120 Y103.942 F10800.000 M204 S800 G1 F900 G1 X140.191 Y103.942 E0.03146 G1 X140.191 Y95.892 E0.27248 G1 X141.120 Y95.892 E0.03146 G1 X141.120 Y103.882 E0.27045 M204 S1000 G1 X140.766 Y103.756 F10800.000 G1 F8640.000 G1 X140.191 Y103.942 E-0.21503 G1 X140.191 Y101.582 E-0.54497 G1 E-0.04000 F2100.00000 G1 Z7.400 F10800.000 G1 X129.327 Y103.564 G1 Z6.800 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X129.212 Y103.564 E0.00390 G1 X129.212 Y96.328 E0.24492 G1 X129.327 Y96.328 E0.00390 G1 X129.327 Y103.504 E0.24289 M204 S1000 G1 X129.734 Y103.971 F10800.000 M204 S800 G1 F900 G1 X128.805 Y103.971 E0.03146 G1 X128.805 Y95.921 E0.27248 G1 X129.734 Y95.921 E0.03146 G1 X129.734 Y103.911 E0.27045 M204 S1000 G1 X129.380 Y103.784 F10800.000 G1 F8640.000 G1 X128.805 Y103.971 E-0.21503 G1 X128.805 Y101.611 E-0.54497 G1 E-0.04000 F2100.00000 G1 Z7.400 F10800.000 G1 X120.706 Y103.564 G1 Z6.800 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X120.591 Y103.564 E0.00390 G1 X120.591 Y96.328 E0.24492 G1 X120.706 Y96.328 E0.00390 G1 X120.706 Y103.504 E0.24289 M204 S1000 G1 X121.113 Y103.971 F10800.000 M204 S800 G1 F900 G1 X120.184 Y103.971 E0.03146 G1 X120.184 Y95.921 E0.27248 G1 X121.113 Y95.921 E0.03146 G1 X121.113 Y103.911 E0.27045 M204 S1000 G1 X120.759 Y103.784 F10800.000 ;BEFORE_LAYER_CHANGE G92 E0.0 ;7 G1 F8640.000 G1 X120.184 Y103.971 E-0.21503 G1 X120.184 Y101.611 E-0.54497 G1 E-0.04000 F2100.00000 G1 Z7.400 F10800.000 ;AFTER_LAYER_CHANGE ;7 G1 X149.117 Y103.535 G1 Z7.000 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X149.117 Y96.299 E0.24492 G1 X149.334 Y96.299 E0.00734 G1 X149.334 Y103.535 E0.24492 G1 X149.177 Y103.535 E0.00531 M204 S1000 G1 X149.741 Y103.942 F10800.000 M204 S800 G1 F900 G1 X148.710 Y103.942 E0.03490 G1 X148.710 Y95.892 E0.27248 G1 X149.741 Y95.892 E0.03490 G1 X149.741 Y103.882 E0.27045 M204 S1000 G1 X149.386 Y103.757 F10800.000 G1 F8640.000 G1 X148.710 Y103.942 E-0.23847 G1 X148.710 Y101.684 E-0.52153 G1 E-0.04000 F2100.00000 G1 Z7.600 F10800.000 G1 X140.815 Y103.535 G1 Z7.000 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X140.598 Y103.535 E0.00734 G1 X140.598 Y96.299 E0.24492 G1 X140.815 Y96.299 E0.00734 G1 X140.815 Y103.475 E0.24289 M204 S1000 G1 X140.191 Y103.942 F10800.000 M204 S800 G1 F900 G1 X140.191 Y95.892 E0.27248 G1 X141.222 Y95.892 E0.03490 G1 X141.222 Y103.942 E0.27248 G1 X140.251 Y103.942 E0.03287 M204 S1000 G1 X140.208 Y103.543 F10800.000 G1 F8640.000 G1 X140.226 Y100.651 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z7.600 F10800.000 G1 X129.327 Y103.564 G1 Z7.000 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X129.110 Y103.564 E0.00734 G1 X129.110 Y96.328 E0.24492 G1 X129.327 Y96.328 E0.00734 G1 X129.327 Y103.504 E0.24289 M204 S1000 G1 X129.734 Y103.971 F10800.000 M204 S800 G1 F900 G1 X128.703 Y103.971 E0.03490 G1 X128.703 Y95.921 E0.27248 G1 X129.734 Y95.921 E0.03490 G1 X129.734 Y103.911 E0.27045 M204 S1000 G1 X129.379 Y103.786 F10800.000 G1 F8640.000 G1 X128.703 Y103.971 E-0.23847 G1 X128.703 Y101.712 E-0.52153 G1 E-0.04000 F2100.00000 G1 Z7.600 F10800.000 G1 X120.808 Y103.564 G1 Z7.000 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X120.591 Y103.564 E0.00734 G1 X120.591 Y96.328 E0.24492 G1 X120.808 Y96.328 E0.00734 G1 X120.808 Y103.504 E0.24289 M204 S1000 G1 X120.184 Y103.971 F10800.000 M204 S800 G1 F900 G1 X120.184 Y95.921 E0.27248 G1 X121.215 Y95.921 E0.03490 G1 X121.215 Y103.971 E0.27248 G1 X120.244 Y103.971 E0.03287 M204 S1000 G1 X120.201 Y103.571 F10800.000 ;BEFORE_LAYER_CHANGE G92 E0.0 ;7.2 G1 F8640.000 G1 X120.219 Y100.680 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z7.600 F10800.000 ;AFTER_LAYER_CHANGE ;7.2 G1 X149.001 Y103.535 G1 Z7.200 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X149.001 Y96.299 E0.24492 G1 X149.334 Y96.299 E0.01127 G1 X149.334 Y103.535 E0.24492 G1 X149.061 Y103.535 E0.00924 M204 S1000 G1 X149.741 Y103.942 F10800.000 M204 S800 G1 F900 G1 X148.594 Y103.942 E0.03883 G1 X148.594 Y95.892 E0.27248 G1 X149.741 Y95.892 E0.03883 G1 X149.741 Y103.882 E0.27045 M204 S1000 G1 X149.386 Y103.759 F10800.000 G1 F8640.000 G1 X148.594 Y103.942 E-0.26523 G1 X148.594 Y101.800 E-0.49477 G1 E-0.04000 F2100.00000 G1 Z7.800 F10800.000 G1 X140.931 Y103.535 G1 Z7.200 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X140.598 Y103.535 E0.01127 G1 X140.598 Y96.299 E0.24492 G1 X140.931 Y96.299 E0.01127 G1 X140.931 Y103.475 E0.24289 M204 S1000 G1 X140.191 Y103.942 F10800.000 M204 S800 G1 F900 G1 X140.191 Y95.892 E0.27248 G1 X141.338 Y95.892 E0.03883 G1 X141.338 Y103.942 E0.27248 G1 X140.251 Y103.942 E0.03680 M204 S1000 G1 X140.210 Y103.543 F10800.000 G1 F8640.000 G1 X140.226 Y100.651 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z7.800 F10800.000 G1 X129.327 Y103.564 G1 Z7.200 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X128.994 Y103.564 E0.01127 G1 X128.994 Y96.328 E0.24492 G1 X129.327 Y96.328 E0.01127 G1 X129.327 Y103.504 E0.24289 M204 S1000 G1 X129.734 Y103.971 F10800.000 M204 S800 G1 F900 G1 X128.587 Y103.971 E0.03883 G1 X128.587 Y95.921 E0.27248 G1 X129.734 Y95.921 E0.03883 G1 X129.734 Y103.911 E0.27045 M204 S1000 G1 X129.378 Y103.788 F10800.000 G1 F8640.000 G1 X128.587 Y103.971 E-0.26523 G1 X128.587 Y101.828 E-0.49477 G1 E-0.04000 F2100.00000 G1 Z7.800 F10800.000 G1 X120.924 Y103.564 G1 Z7.200 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X120.591 Y103.564 E0.01127 G1 X120.591 Y96.328 E0.24492 G1 X120.924 Y96.328 E0.01127 G1 X120.924 Y103.504 E0.24289 M204 S1000 G1 X120.184 Y103.971 F10800.000 M204 S800 G1 F900 G1 X120.184 Y95.921 E0.27248 G1 X121.331 Y95.921 E0.03883 G1 X121.331 Y103.971 E0.27248 G1 X120.244 Y103.971 E0.03680 M204 S1000 G1 X120.203 Y103.571 F10800.000 ;BEFORE_LAYER_CHANGE G92 E0.0 ;7.4 G1 F8640.000 G1 X120.219 Y100.680 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z7.800 F10800.000 ;AFTER_LAYER_CHANGE ;7.4 G1 X148.869 Y103.535 G1 Z7.400 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X148.869 Y96.299 E0.24492 G1 X149.334 Y96.299 E0.01574 G1 X149.334 Y103.535 E0.24492 G1 X148.929 Y103.535 E0.01371 M204 S1000 G1 X149.741 Y103.942 F10800.000 M204 S800 G1 F900 G1 X148.462 Y103.942 E0.04330 G1 X148.462 Y95.892 E0.27248 G1 X149.741 Y95.892 E0.04330 G1 X149.741 Y103.882 E0.27045 M204 S1000 G1 X149.385 Y103.761 F10800.000 G1 F8640.000 G1 X148.462 Y103.942 E-0.29569 G1 X148.462 Y101.932 E-0.46431 M73 Q41 S13 G1 E-0.04000 F2100.00000 G1 Z8.000 F10800.000 G1 X149.101 Y96.503 G1 Z7.400 G1 E0.80000 F2100.00000 G1 F900 G1 X149.101 Y103.332 E0.03290 G1 F8640.000 G1 X149.101 Y100.040 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z8.000 F10800.000 G1 X141.063 Y103.535 G1 Z7.400 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X140.598 Y103.535 E0.01574 G1 X140.598 Y96.299 E0.24492 G1 X141.063 Y96.299 E0.01574 G1 X141.063 Y103.475 E0.24289 M204 S1000 G1 X140.191 Y103.942 F10800.000 M204 S800 G1 F900 G1 X140.191 Y95.892 E0.27248 G1 X141.470 Y95.892 E0.04330 G1 X141.470 Y103.942 E0.27248 M73 P41 R13 G1 X140.251 Y103.942 E0.04127 M204 S1000 G1 X140.212 Y103.543 F10800.000 G1 F8640.000 G1 X140.226 Y100.651 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z8.000 F10800.000 G1 X140.831 Y96.503 G1 Z7.400 G1 E0.80000 F2100.00000 G1 F900 G1 X140.831 Y103.332 E0.03290 G1 F8640.000 G1 X140.831 Y100.040 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z8.000 F10800.000 G1 X129.327 Y103.564 G1 Z7.400 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X128.862 Y103.564 E0.01574 G1 X128.862 Y96.328 E0.24492 G1 X129.327 Y96.328 E0.01574 G1 X129.327 Y103.504 E0.24289 M204 S1000 G1 X129.734 Y103.971 F10800.000 M204 S800 G1 F900 G1 X128.455 Y103.971 E0.04330 G1 X128.455 Y95.921 E0.27248 G1 X129.734 Y95.921 E0.04330 G1 X129.734 Y103.911 E0.27045 M204 S1000 G1 X129.377 Y103.790 F10800.000 G1 F8640.000 G1 X128.455 Y103.971 E-0.29569 G1 X128.455 Y101.960 E-0.46431 G1 E-0.04000 F2100.00000 G1 Z8.000 F10800.000 G1 X129.094 Y96.532 G1 Z7.400 G1 E0.80000 F2100.00000 G1 F900 G1 X129.094 Y103.360 E0.03290 G1 F8640.000 G1 X129.094 Y100.069 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z8.000 F10800.000 G1 X121.056 Y103.564 G1 Z7.400 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X120.591 Y103.564 E0.01574 G1 X120.591 Y96.328 E0.24492 G1 X121.056 Y96.328 E0.01574 G1 X121.056 Y103.504 E0.24289 M204 S1000 G1 X120.184 Y103.971 F10800.000 M204 S800 G1 F900 G1 X120.184 Y95.921 E0.27248 G1 X121.463 Y95.921 E0.04330 G1 X121.463 Y103.971 E0.27248 G1 X120.244 Y103.971 E0.04127 M204 S1000 G1 X120.205 Y103.572 F10800.000 G1 F8640.000 G1 X120.219 Y100.680 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z8.000 F10800.000 G1 X120.823 Y96.532 G1 Z7.400 G1 E0.80000 F2100.00000 G1 F900 G1 X120.823 Y103.360 E0.03290 ;BEFORE_LAYER_CHANGE G92 E0.0 ;7.6 G1 F8640.000 G1 X120.823 Y100.069 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z8.000 F10800.000 ;AFTER_LAYER_CHANGE ;7.6 G1 X149.334 Y103.535 G1 Z7.600 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X148.719 Y103.535 E0.02083 G1 X148.719 Y96.299 E0.24492 G1 X149.334 Y96.299 E0.02083 G1 X149.334 Y103.475 E0.24289 M204 S1000 G1 X149.741 Y103.942 F10800.000 M204 S800 G1 F900 G1 X148.312 Y103.942 E0.04838 G1 X148.312 Y95.892 E0.27248 G1 X149.741 Y95.892 E0.04838 G1 X149.741 Y103.882 E0.27045 M204 S1000 G1 X149.383 Y103.763 F10800.000 G1 F8640.000 G1 X148.312 Y103.942 E-0.33034 G1 X148.312 Y102.082 E-0.42966 G1 E-0.04000 F2100.00000 G1 Z8.200 F10800.000 G1 X149.026 Y96.503 G1 Z7.600 G1 E0.80000 F2100.00000 G1 F900 G1 X149.026 Y103.332 E0.11820 G1 F8640.000 G1 X149.026 Y100.040 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z8.200 F10800.000 G1 X141.213 Y103.535 G1 Z7.600 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X140.598 Y103.535 E0.02083 G1 X140.598 Y96.299 E0.24492 G1 X141.213 Y96.299 E0.02083 G1 X141.213 Y103.475 E0.24289 M204 S1000 G1 F8640.000 G1 X140.598 Y103.535 E-0.14274 G1 X140.598 Y100.862 E-0.61727 G1 E-0.04000 F2100.00000 G1 Z8.200 F10800.000 G1 X140.191 Y103.942 G1 Z7.600 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X140.191 Y95.892 E0.27248 G1 X141.620 Y95.892 E0.04838 G1 X141.620 Y103.942 E0.27248 G1 X140.251 Y103.942 E0.04635 M204 S1000 G1 X140.214 Y103.543 F10800.000 G1 F8640.000 G1 X140.226 Y100.651 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z8.200 F10800.000 G1 X140.906 Y96.503 G1 Z7.600 G1 E0.80000 F2100.00000 G1 F900 G1 X140.906 Y103.332 E0.11820 G1 F8640.000 G1 X140.906 Y100.040 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z8.200 F10800.000 G1 X129.327 Y103.564 G1 Z7.600 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X128.712 Y103.564 E0.02083 G1 X128.712 Y96.328 E0.24492 G1 X129.327 Y96.328 E0.02083 G1 X129.327 Y103.504 E0.24289 M204 S1000 G1 X129.734 Y103.971 F10800.000 M204 S800 G1 F900 G1 X128.304 Y103.971 E0.04838 G1 X128.304 Y95.921 E0.27248 G1 X129.734 Y95.921 E0.04838 G1 X129.734 Y103.911 E0.27045 M204 S1000 G1 X129.376 Y103.792 F10800.000 G1 F8640.000 G1 X128.304 Y103.971 E-0.33034 G1 X128.304 Y102.110 E-0.42966 G1 E-0.04000 F2100.00000 G1 Z8.200 F10800.000 G1 X129.019 Y96.532 G1 Z7.600 G1 E0.80000 F2100.00000 G1 F900 G1 X129.019 Y103.360 E0.11820 G1 F8640.000 G1 X129.019 Y100.069 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z8.200 F10800.000 G1 X121.206 Y103.564 G1 Z7.600 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X120.591 Y103.564 E0.02083 G1 X120.591 Y96.328 E0.24492 G1 X121.206 Y96.328 E0.02083 G1 X121.206 Y103.504 E0.24289 M204 S1000 G1 F8640.000 G1 X120.591 Y103.564 E-0.14274 G1 X120.591 Y100.891 E-0.61727 G1 E-0.04000 F2100.00000 G1 Z8.200 F10800.000 G1 X120.184 Y103.971 G1 Z7.600 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X120.184 Y95.921 E0.27248 G1 X121.613 Y95.921 E0.04838 G1 X121.613 Y103.971 E0.27248 G1 X120.244 Y103.971 E0.04635 M204 S1000 G1 X120.207 Y103.572 F10800.000 G1 F8640.000 G1 X120.219 Y100.680 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z8.200 F10800.000 G1 X120.899 Y96.532 G1 Z7.600 G1 E0.80000 F2100.00000 G1 F900 G1 X120.899 Y103.360 E0.11820 ;BEFORE_LAYER_CHANGE G92 E0.0 ;7.8 G1 F8640.000 G1 X120.899 Y100.069 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z8.200 F10800.000 ;AFTER_LAYER_CHANGE ;7.8 G1 X149.334 Y103.535 G1 Z7.800 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X148.548 Y103.535 E0.02662 G1 X148.548 Y96.299 E0.24492 G1 X149.334 Y96.299 E0.02662 G1 X149.334 Y103.475 E0.24289 M204 S1000 G1 X149.741 Y103.942 F10800.000 M204 S800 G1 F900 G1 X148.141 Y103.942 E0.05417 G1 X148.141 Y95.892 E0.27248 G1 X149.741 Y95.892 E0.05417 G1 X149.741 Y103.882 E0.27045 M204 S1000 G1 X149.382 Y103.765 F10800.000 G1 F8640.000 G1 X148.141 Y103.942 E-0.36981 G1 X148.141 Y102.253 E-0.39019 G1 E-0.04000 F2100.00000 G1 Z8.400 F10800.000 G1 X148.941 Y96.503 G1 Z7.800 G1 E0.80000 F2100.00000 G1 F900 G1 X148.941 Y103.332 E0.21533 G1 F8640.000 G1 X148.941 Y100.040 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z8.400 F10800.000 G1 X141.384 Y103.535 G1 Z7.800 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X140.598 Y103.535 E0.02662 G1 X140.598 Y96.299 E0.24492 G1 X141.384 Y96.299 E0.02662 G1 X141.384 Y103.475 E0.24289 M204 S1000 G1 F8640.000 G1 X140.598 Y103.535 E-0.18209 G1 X140.598 Y101.032 E-0.57791 G1 E-0.04000 F2100.00000 G1 Z8.400 F10800.000 G1 X140.191 Y103.942 G1 Z7.800 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X140.191 Y95.892 E0.27248 G1 X141.791 Y95.892 E0.05417 G1 X141.791 Y103.942 E0.27248 G1 X140.251 Y103.942 E0.05214 M204 S1000 G1 X140.217 Y103.543 F10800.000 G1 F8640.000 G1 X140.226 Y100.651 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z8.400 F10800.000 G1 X140.991 Y96.503 G1 Z7.800 G1 E0.80000 F2100.00000 G1 F900 G1 X140.991 Y103.332 E0.21532 G1 F8640.000 G1 X140.991 Y100.040 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z8.400 F10800.000 G1 X129.327 Y103.564 G1 Z7.800 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X128.540 Y103.564 E0.02662 G1 X128.540 Y96.328 E0.24492 G1 X129.327 Y96.328 E0.02662 G1 X129.327 Y103.504 E0.24289 M204 S1000 G1 X129.734 Y103.971 F10800.000 M204 S800 G1 F900 G1 X128.133 Y103.971 E0.05417 G1 X128.133 Y95.921 E0.27248 G1 X129.734 Y95.921 E0.05417 G1 X129.734 Y103.911 E0.27045 M204 S1000 G1 X129.375 Y103.794 F10800.000 G1 F8640.000 G1 X128.133 Y103.971 E-0.36981 G1 X128.133 Y102.281 E-0.39019 G1 E-0.04000 F2100.00000 G1 Z8.400 F10800.000 G1 X128.934 Y96.532 G1 Z7.800 G1 E0.80000 F2100.00000 G1 F900 G1 X128.934 Y103.360 E0.21533 G1 F8640.000 G1 X128.934 Y100.069 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z8.400 F10800.000 G1 X121.377 Y103.564 G1 Z7.800 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X120.591 Y103.564 E0.02662 G1 X120.591 Y96.328 E0.24492 G1 X121.377 Y96.328 E0.02662 G1 X121.377 Y103.504 E0.24289 M204 S1000 G1 F8640.000 G1 X120.591 Y103.564 E-0.18209 G1 X120.591 Y101.061 E-0.57791 G1 E-0.04000 F2100.00000 G1 Z8.400 F10800.000 G1 X120.184 Y103.971 G1 Z7.800 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X120.184 Y95.921 E0.27248 G1 X121.784 Y95.921 E0.05417 G1 X121.784 Y103.971 E0.27248 G1 X120.244 Y103.971 E0.05214 M204 S1000 G1 X120.210 Y103.572 F10800.000 G1 F8640.000 G1 X120.219 Y100.680 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z8.400 F10800.000 G1 X120.984 Y96.532 G1 Z7.800 G1 E0.80000 F2100.00000 G1 F900 G1 X120.984 Y103.360 E0.21532 ;BEFORE_LAYER_CHANGE G92 E0.0 ;8 G1 F8640.000 G1 X120.984 Y100.069 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z8.400 F10800.000 ;AFTER_LAYER_CHANGE ;8 G1 X149.334 Y103.535 G1 Z8.000 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X148.352 Y103.535 E0.03323 G1 X148.352 Y96.299 E0.24492 G1 X149.334 Y96.299 E0.03323 G1 X149.334 Y103.475 E0.24289 M204 S1000 G1 X149.741 Y103.942 F10800.000 M204 S800 G1 F900 G1 X147.945 Y103.942 E0.06079 G1 X147.945 Y95.892 E0.27248 G1 X149.741 Y95.892 E0.06079 G1 X149.741 Y103.882 E0.27045 M204 S1000 G1 X149.381 Y103.768 F10800.000 G1 F8640.000 G1 X147.945 Y103.942 E-0.41492 G1 X147.945 Y102.448 E-0.34508 G1 E-0.04000 F2100.00000 G1 Z8.600 F10800.000 G1 X149.212 Y96.544 G1 Z8.000 G1 E0.80000 F2100.00000 G1 F900 G1 X148.657 Y97.099 E0.02770 G1 X148.657 Y97.700 E0.02122 G1 X149.029 Y97.328 E0.01854 G1 X149.029 Y97.929 E0.02122 G1 X148.657 Y98.300 E0.01854 G1 X148.657 Y98.901 E0.02122 G1 X149.029 Y98.530 E0.01854 G1 X149.029 Y99.131 E0.02122 G1 X148.657 Y99.502 E0.01854 G1 X148.657 Y100.103 E0.02122 G1 X149.029 Y99.732 E0.01854 G1 X149.029 Y100.333 E0.02122 G1 X148.657 Y100.704 E0.01854 G1 X148.657 Y101.305 E0.02122 G1 X149.029 Y100.933 E0.01854 G1 X149.029 Y101.534 E0.02122 G1 X148.657 Y101.905 E0.01854 G1 X148.657 Y102.506 E0.02122 G1 X149.029 Y102.135 E0.01854 G1 X149.029 Y102.736 E0.02122 G1 X148.474 Y103.290 E0.02770 G1 F8640.000 G1 X149.029 Y102.736 E-0.18103 G1 X149.029 Y102.135 E-0.13873 G1 X148.657 Y102.506 E-0.12121 G1 X148.657 Y101.905 E-0.13873 G1 X149.029 Y101.534 E-0.12121 G1 X149.029 Y101.278 E-0.05910 G1 E-0.04000 F2100.00000 G1 Z8.600 F10800.000 G1 X141.580 Y103.535 G1 Z8.000 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X140.598 Y103.535 E0.03323 G1 X140.598 Y96.299 E0.24492 G1 X141.580 Y96.299 E0.03323 G1 X141.580 Y103.475 E0.24289 M204 S1000 G1 F8640.000 G1 X140.598 Y103.535 E-0.22712 G1 X140.598 Y101.227 E-0.53288 G1 E-0.04000 F2100.00000 G1 Z8.600 F10800.000 G1 X140.191 Y103.942 G1 Z8.000 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X140.191 Y95.892 E0.27248 G1 X141.987 Y95.892 E0.06079 G1 X141.987 Y103.942 E0.27248 G1 X140.251 Y103.942 E0.05876 M204 S1000 G1 X140.220 Y103.543 F10800.000 G1 F8640.000 G1 X140.226 Y100.651 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z8.600 F10800.000 G1 X141.458 Y96.544 G1 Z8.000 G1 E0.80000 F2100.00000 G1 F900 G1 X140.903 Y97.099 E0.02770 G1 X140.903 Y97.700 E0.02122 G1 X141.275 Y97.328 E0.01854 G1 X141.275 Y97.929 E0.02122 G1 X140.903 Y98.300 E0.01854 G1 X140.903 Y98.901 E0.02122 G1 X141.275 Y98.530 E0.01854 G1 X141.275 Y99.131 E0.02122 G1 X140.903 Y99.502 E0.01854 G1 X140.903 Y100.103 E0.02122 G1 X141.275 Y99.732 E0.01854 G1 X141.275 Y100.333 E0.02122 G1 X140.903 Y100.704 E0.01854 G1 X140.903 Y101.305 E0.02122 G1 X141.275 Y100.933 E0.01854 G1 X141.275 Y101.534 E0.02122 G1 X140.903 Y101.905 E0.01854 G1 X140.903 Y102.506 E0.02122 G1 X141.275 Y102.135 E0.01854 G1 X141.275 Y102.736 E0.02122 G1 X140.720 Y103.290 E0.02770 G1 F8640.000 G1 X141.275 Y102.736 E-0.18103 G1 X141.275 Y102.135 E-0.13873 G1 X140.903 Y102.506 E-0.12121 G1 X140.903 Y101.905 E-0.13873 G1 X141.275 Y101.534 E-0.12121 G1 X141.275 Y101.278 E-0.05910 G1 E-0.04000 F2100.00000 G1 Z8.600 F10800.000 G1 X129.327 Y103.564 G1 Z8.000 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X128.345 Y103.564 E0.03323 G1 X128.345 Y96.328 E0.24492 G1 X129.327 Y96.328 E0.03323 G1 X129.327 Y103.504 E0.24289 M204 S1000 G1 X129.734 Y103.971 F10800.000 M204 S800 G1 F900 G1 X127.938 Y103.971 E0.06079 G1 X127.938 Y95.921 E0.27248 G1 X129.734 Y95.921 E0.06079 G1 X129.734 Y103.911 E0.27045 M204 S1000 G1 X129.374 Y103.797 F10800.000 G1 F8640.000 G1 X127.938 Y103.971 E-0.41492 G1 X127.938 Y102.477 E-0.34508 G1 E-0.04000 F2100.00000 G1 Z8.600 F10800.000 G1 X129.205 Y96.573 G1 Z8.000 G1 E0.80000 F2100.00000 G1 F900 G1 X128.650 Y97.128 E0.02770 G1 X128.650 Y97.728 E0.02122 G1 X129.021 Y97.357 E0.01854 G1 X129.021 Y97.958 E0.02122 G1 X128.650 Y98.329 E0.01854 G1 X128.650 Y98.930 E0.02122 G1 X129.021 Y98.559 E0.01854 G1 X129.021 Y99.160 E0.02122 G1 X128.650 Y99.531 E0.01854 G1 X128.650 Y100.132 E0.02122 G1 X129.021 Y99.760 E0.01854 G1 X129.021 Y100.361 E0.02122 G1 X128.650 Y100.732 E0.01854 G1 X128.650 Y101.333 E0.02122 G1 X129.021 Y100.962 E0.01854 G1 X129.021 Y101.563 E0.02122 G1 X128.650 Y101.934 E0.01854 G1 X128.650 Y102.535 E0.02122 G1 X129.021 Y102.164 E0.01854 G1 X129.021 Y102.764 E0.02122 G1 X128.467 Y103.319 E0.02770 G1 F8640.000 G1 X129.021 Y102.764 E-0.18103 G1 X129.021 Y102.164 E-0.13873 G1 X128.650 Y102.535 E-0.12121 G1 X128.650 Y101.934 E-0.13873 G1 X129.021 Y101.563 E-0.12121 G1 X129.021 Y101.307 E-0.05910 G1 E-0.04000 F2100.00000 G1 Z8.600 F10800.000 G1 X121.573 Y103.564 G1 Z8.000 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X120.591 Y103.564 E0.03323 G1 X120.591 Y96.328 E0.24492 G1 X121.573 Y96.328 E0.03323 G1 X121.573 Y103.504 E0.24289 M204 S1000 G1 F8640.000 G1 X120.591 Y103.564 E-0.22712 G1 X120.591 Y101.256 E-0.53288 G1 E-0.04000 F2100.00000 G1 Z8.600 F10800.000 G1 X120.184 Y103.971 G1 Z8.000 G1 E0.80000 F2100.00000 M204 S800 G1 F900 G1 X120.184 Y95.921 E0.27248 G1 X121.980 Y95.921 E0.06079 G1 X121.980 Y103.971 E0.27248 M73 Q45 S12 G1 X120.244 Y103.971 E0.05876 M204 S1000 G1 X120.213 Y103.572 F10800.000 G1 F8640.000 G1 X120.219 Y100.680 E-0.76000 G1 E-0.04000 F2100.00000 G1 Z8.600 F10800.000 G1 X121.451 Y96.573 G1 Z8.000 G1 E0.80000 F2100.00000 G1 F900 G1 X120.896 Y97.128 E0.02770 G1 X120.896 Y97.728 E0.02122 G1 X121.267 Y97.357 E0.01854 G1 X121.267 Y97.958 E0.02122 G1 X120.896 Y98.329 E0.01854 G1 X120.896 Y98.930 E0.02122 G1 X121.267 Y98.559 E0.01854 G1 X121.267 Y99.160 E0.02122 G1 X120.896 Y99.531 E0.01854 G1
| 33,481
|
https://github.com/Mikey-Beep/DockerSVN/blob/master/cgi-bin/newuser.py
|
Github Open Source
|
Open Source
|
MIT
| null |
DockerSVN
|
Mikey-Beep
|
Python
|
Code
| 125
| 518
|
#!/usr/bin/env python3
# Import modules for CGI handling
import cgi, cgitb, subprocess
cgitb.enable()
def check_user(user_name):
command = ['htpasswd', '-vb', '/etc/subversion/passwd', user_name, '-']
return subprocess.run(command, stdout = subprocess.DEVNULL, stderr = subprocess.DEVNULL).returncode
def check_passwds_match(passwd_1, passwd_2):
return passwd_1 == passwd_2
def add_user(user_name, new_passwd):
command = ['htpasswd', '-b', '/etc/subversion/passwd', user_name, new_passwd]
return subprocess.run(command, stdout = subprocess.DEVNULL, stderr = subprocess.DEVNULL).returncode
# Create instance of FieldStorage
form = cgi.FieldStorage()
# Get data from fields
user_name = form.getvalue('user_name')
new_passwd = form.getvalue('new_passwd')
confirm_new_passwd = form.getvalue('confirm_new_passwd')
if check_user(user_name) == 6:
if check_passwds_match(new_passwd, confirm_new_passwd):
add_user(user_name, new_passwd)
end_state = 'Success'
result_str = f'User: {user_name} successfully added.'
else:
end_state = 'Failed'
result_str = 'Mismatch between new password entries.'
else:
end_state = 'Failed'
result_str = f'User: {user_name} already exists.'
print('Content-type:text/html\r\n\r\n')
print('<html>')
print('<head>')
print(f'<title>{end_state}</title>')
print('</head>')
print('<body>')
print(f'<p>{result_str}</p>')
print('</body>')
print('</html>')
| 44,647
|
https://github.com/uh-manoa-meteorites/nonprofit-project-template/blob/master/app/tests/organizationlibrary.page.js
|
Github Open Source
|
Open Source
|
MIT
| null |
nonprofit-project-template
|
uh-manoa-meteorites
|
JavaScript
|
Code
| 77
| 251
|
import { Selector, t } from 'testcafe';
import { PAGE_IDS } from '../imports/ui/utilities/PageIDs';
import { COMPONENT_IDS } from '../imports/ui/utilities/ComponentIDs';
class OrganizationLibraryPage {
constructor() {
this.pageId = `#${PAGE_IDS.ORGANIZATION_LIB}`;
this.pageSelector = Selector(this.pageId);
this.cardId = `#${COMPONENT_IDS.ORGANIZATION_LIB_CARD}`;
this.cardSelector = Selector(this.cardId);
}
/** Asserts that this page is currently displayed. */
async isDisplayed() {
await t.expect(this.pageSelector.exists).ok();
}
/** Asserts that org card in this page is currently displayed. */
async isOrgCardDisplayed() {
await t.expect(this.cardSelector.exists).ok();
}
}
export const organizationLibraryPage = new OrganizationLibraryPage();
| 41,792
|
https://github.com/octaveEtard/sigTools/blob/master/functions/+sigTools/fft.m
|
Github Open Source
|
Open Source
|
MIT
| 2,020
|
sigTools
|
octaveEtard
|
MATLAB
|
Code
| 238
| 608
|
function [fT, F] = fft(data,varargin)
% fft performs and return one sided FFT & associated frequencies
%
% Usage: fft(data, ...)
%
% Required input:
% data array npoints x ndimension: FFT will be performed for
% each column separately
%
% Optional inputs:
% Fs integer default = 1
% nFFT integer default = 2^(nextpow2(npoints))
% maxF double default = Fs / 2
% minF double default = 0
%% default values
ip = inputParser;
npoints = size(data,1);
ip.addRequired('data', @isnumeric);
ip.addOptional('Fs', 1, @isnumeric);
ip.addOptional('nFFT', 2^(nextpow2(npoints)), @isnumeric);
ip.addOptional('maxF', -1, @isnumeric);
ip.addOptional('minF', 0, @isnumeric);
ip.parse(data,varargin{:});
Fs = ip.Results.Fs;
nFFT = ip.Results.nFFT;
maxF = ip.Results.maxF;
minF = ip.Results.minF;
%% the FFT will return nF frequencies, integer multiples of df = Fs/nFFT
nF = ceil((nFFT+1)/2);
df = Fs / nFFT;
F = (0:(nF-1)) * df;
%% Fourier coefficients
% scaling to account for how Matlab scales coefficients
fT = 2 * fft(data, nFFT) / nFFT;
% keeping only half of the spectrum
fT = fT(1:nF, :);
%% only keeping the required frequencies
if maxF > 0 && maxF < F(end)
kmax = floor(maxF / df ) + 1;
else
kmax = nF;
end
if minF > 0 && minF < (Fs/2)
kmin = floor(minF / df ) +1;
else
kmin = 1;
end
fT = fT(kmin:kmax, :);
% in case fT has more than 2 dimensions
s = size(data);
s(1) = kmax-kmin+1;
fT = reshape(fT,s);
F = F(kmin:kmax);
end
%
%
| 42,229
|
https://github.com/deanlinsalata/JALoP/blob/master/src/network_lib/src/jaln_publisher_callbacks.c
|
Github Open Source
|
Open Source
|
Apache-2.0
| 2,021
|
JALoP
|
deanlinsalata
|
C
|
Code
| 270
| 838
|
/**
* @file jaln_publisher_callbacks.c This file contains jaln_publisher_callback functions
*
* @section LICENSE
*
* Source code in 3rd-party is licensed and owned by their respective
* copyright holders.
*
* All other source code is copyright Tresys Technology and licensed as below.
*
* Copyright (c) 2011 Tresys Technology LLC, Columbia, Maryland, USA
*
* This software was developed by Tresys Technology LLC
* with U.S. Government sponsorship.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <stdlib.h>
#include <string.h>
#include <jalop/jal_status.h>
#include <jalop/jaln_publisher_callbacks.h>
#include "jaln_publisher_callbacks_internal.h"
#include "jaln_context.h"
#include "jal_alloc.h"
struct jaln_publisher_callbacks *jaln_publisher_callbacks_create()
{
struct jaln_publisher_callbacks *new_pub_callbacks;
new_pub_callbacks = jal_calloc(1, sizeof(*new_pub_callbacks));
return new_pub_callbacks;
}
void jaln_publisher_callbacks_destroy(struct jaln_publisher_callbacks **pub_callbacks)
{
if (!pub_callbacks || !(*pub_callbacks)) {
return;
}
free(*pub_callbacks);
*pub_callbacks = NULL;
}
int jaln_publisher_callbacks_is_valid(struct jaln_publisher_callbacks *publisher_callbacks)
{
if (!publisher_callbacks ||
!publisher_callbacks->on_journal_resume ||
!publisher_callbacks->on_subscribe ||
!publisher_callbacks->on_record_complete ||
!publisher_callbacks->sync ||
!publisher_callbacks->notify_digest ||
!publisher_callbacks->peer_digest) {
return 0;
}
return 1;
}
enum jal_status jaln_register_publisher_callbacks(jaln_context *jaln_ctx,
struct jaln_publisher_callbacks *publisher_callbacks)
{
if (!jaln_ctx || jaln_ctx->pub_callbacks) {
return JAL_E_INVAL;
}
struct jaln_publisher_callbacks *new_callbacks = NULL;
if (!jaln_publisher_callbacks_is_valid(publisher_callbacks)) {
return JAL_E_INVAL;
}
new_callbacks = jaln_publisher_callbacks_create();
memcpy(new_callbacks, publisher_callbacks, sizeof(*new_callbacks));
jaln_ctx->pub_callbacks = new_callbacks;
return JAL_OK;
}
| 27,065
|
https://github.com/ahd985/simvis/blob/master/simvis/static/js/build/containers/rightSidebar.js
|
Github Open Source
|
Open Source
|
MIT
| null |
simvis
|
ahd985
|
JavaScript
|
Code
| 1,596
| 5,525
|
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _semanticUiReact = require('semantic-ui-react');
var _reactRedux = require('react-redux');
var _actions = require('../actions');
var _numberPicker = require('../components/numberPicker');
var _numberPicker2 = _interopRequireDefault(_numberPicker);
var _colorPickerModal = require('../components/colorPickerModal');
var _colorPickerModal2 = _interopRequireDefault(_colorPickerModal);
var _modelPickerModal = require('../components/modelPickerModal');
var _modelPickerModal2 = _interopRequireDefault(_modelPickerModal);
var _dataImport = require('./dataImport.jsx');
var _dataImport2 = _interopRequireDefault(_dataImport);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var RightSideBarMenu = function (_Component) {
_inherits(RightSideBarMenu, _Component);
function RightSideBarMenu(props) {
_classCallCheck(this, RightSideBarMenu);
var _this = _possibleConstructorReturn(this, (RightSideBarMenu.__proto__ || Object.getPrototypeOf(RightSideBarMenu)).call(this, props));
_this.state = {
visible: true,
activeItem: 'model'
};
_this.handleTabClick = _this.handleTabClick.bind(_this);
_this.handleStrokeWidthChange = _this.handleStrokeWidthChange.bind(_this);
_this.handleFontSizeChange = _this.handleFontSizeChange.bind(_this);
_this.handleOverviewChange = _this.handleOverviewChange.bind(_this);
_this.handlePositionChange = _this.handlePositionChange.bind(_this);
_this.handleDimChange = _this.handleDimChange.bind(_this);
return _this;
}
_createClass(RightSideBarMenu, [{
key: 'handleTabClick',
value: function handleTabClick(e, _ref) {
var name = _ref.name;
this.setState({ activeItem: name });
}
}, {
key: 'handleStrokeWidthChange',
value: function handleStrokeWidthChange(e) {
this.props.setShapeStyle({ strokeWidth: e.value + '' });
}
}, {
key: 'handleFontSizeChange',
value: function handleFontSizeChange(e) {
this.props.setShapeStyle({ fontSize: e.value + '' });
}
}, {
key: 'handleOverviewChange',
value: function handleOverviewChange(e, arg) {
e.persist ? e.persist() : null;
this.props.setOverview(_extends({}, this.props.overview, _defineProperty({}, arg, e.value ? e.value : e.target.value)));
}
}, {
key: 'handlePositionChange',
value: function handlePositionChange(prop, val) {
var deltaShapeSize = { x: 0, y: 0, width: 0, height: 0 };
deltaShapeSize[prop] = val;
this.props.resizeShapes(deltaShapeSize);
}
}, {
key: 'handleDimChange',
value: function handleDimChange(prop, val) {
var deltaShapeSize = { x: 0, y: 0, width: 0, height: 0 };
deltaShapeSize[prop] = val;
this.props.resizeShapes(deltaShapeSize);
}
}, {
key: 'render',
value: function render() {
var _this2 = this;
var visible = this.state.visible;
var activeItem = this.state.activeItem;
var style = { width: this.props.rightSideBarWidth, right: 0, textAlign: "center" };
var styleEditable = true;
var fillEditable = true;
var modelEditable = true;
var textEditable = true;
var selectedShape = null;
// Loop through shapes and see if any shape is not editable for style or text
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = this.props.shapes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var shapeData = _step.value;
if (this.props.selectedShapes.indexOf(shapeData.uuid) > -1) {
var shape = shapeData.shape;
if (shape.editable) {
if (shape.editable.style == false) {
styleEditable = false;
}
if (shape.editable.fill == false) {
fillEditable = false;
}
if (shape.editable.text == false) {
textEditable = false;
}
if (shape.editable.model == false) {
modelEditable = false;
}
}
selectedShape = shapeData;
}
}
// Greater than one shape and we can't edit model
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator.return) {
_iterator.return();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
if (this.props.selectedShapes.length > 1) {
modelEditable = false;
}
// TODO - this isn't perfect
activeItem == 'model' && modelEditable == false ? activeItem = 'style' : null;
activeItem == 'style' && styleEditable == false ? activeItem = 'model' : null;
activeItem == 'text' && textEditable == false ? activeItem = 'model' : null;
var submenu = void 0,
menu = void 0;
if (!this.props.selectedShapes.length) {
submenu = null;
menu = _react2.default.createElement(
'div',
{ id: 'right-sidebar', style: style },
_react2.default.createElement(
_semanticUiReact.Segment,
{ size: 'mini', attached: true },
'Overview'
),
_react2.default.createElement(
_semanticUiReact.Form,
{ size: 'small', style: { padding: 5 } },
_react2.default.createElement(_semanticUiReact.Form.Input, { label: 'Title', name: 'title', type: 'text', placeholder: 'My Simulation', value: this.props.overview.title, onChange: function onChange(e) {
return _this2.handleOverviewChange(e, "title");
} }),
_react2.default.createElement(
_semanticUiReact.Form.Group,
{ widths: 'equal' },
_react2.default.createElement(_semanticUiReact.Form.Input, { label: 'X Series Unit', name: 'x_series_unit', type: 'text', placeholder: 'e.g., Hrs', value: this.props.overview.x_series_unit, onChange: function onChange(e) {
return _this2.handleOverviewChange(e, "x_series_unit");
} }),
_react2.default.createElement(_semanticUiReact.Form.Input, { label: 'Font Size', name: 'font_size', type: 'number', value: this.props.overview.font_size, onChange: function onChange(e) {
return _this2.handleOverviewChange(e, "font_size");
}, min: 1, max: 72 })
)
),
_react2.default.createElement(
_semanticUiReact.Segment,
{ size: 'mini', attached: true },
'Layout'
),
_react2.default.createElement(
_semanticUiReact.Form,
{ size: 'small', style: { padding: 5 } },
_react2.default.createElement(
_semanticUiReact.Label,
{ attached: 'top' },
'Width x Height'
),
_react2.default.createElement(
_semanticUiReact.Form.Group,
{ widths: 'equal' },
_react2.default.createElement(
_semanticUiReact.Form.Field,
null,
_react2.default.createElement(_semanticUiReact.Input, { labelPosition: 'right', label: 'px', name: 'diagram_width', type: 'number', value: this.props.diagramWidth, onChange: function onChange(e) {
return _this2.props.setLayout("diagramWidth", parseInt(e.target.value));
}, min: 1, max: 10000 })
),
_react2.default.createElement(
_semanticUiReact.Form.Field,
null,
_react2.default.createElement(_semanticUiReact.Input, { labelPosition: 'right', label: 'px', name: 'diagram_height', type: 'number', value: this.props.diagramHeight, onChange: function onChange(e) {
return _this2.props.setLayout("diagramHeight", parseInt(e.target.value));
}, min: 1, max: 10000 })
)
)
)
);
} else {
if (activeItem === 'model') {
if (!this.props.data) {
submenu = _react2.default.createElement(
_semanticUiReact.Segment,
{ attached: 'bottom', className: 'shapes-selected-menu' },
_react2.default.createElement(
_semanticUiReact.Form,
{ size: 'small', style: { padding: 5 }, as: 'none' },
_react2.default.createElement(
_semanticUiReact.Form.Group,
{ widths: 'equal' },
_react2.default.createElement(
_semanticUiReact.Form.Field,
null,
_react2.default.createElement(_dataImport2.default, { asForm: true })
)
)
)
);
} else {
// TODO - check for conflicting models
var selectedShapes = this.props.shapes.filter(function (shape) {
if (_this2.props.selectedShapes.includes(shape.uuid)) {
return true;
}
return false;
});
var selectedShapeData = selectedShapes[0];
var selectedModel = selectedShapeData.model;
var allowedModels = selectedShapeData.shape.allowedModels;
var allowedConditions = selectedShapeData.shape.allowedConditions;
submenu = _react2.default.createElement(
_semanticUiReact.Segment,
{ attached: 'bottom', className: 'shapes-selected-menu' },
_react2.default.createElement(
_semanticUiReact.Form,
{ size: 'small', style: { padding: 5 }, as: 'none' },
_react2.default.createElement(_modelPickerModal2.default, { allowedModels: allowedModels, allowedConditions: allowedConditions, model: selectedModel, setShapeModel: this.props.setShapeModel, ids: this.props.selectedShapes, data: this.props.data, dataHeaders: this.props.dataHeaders })
)
);
}
} else if (activeItem === 'style') {
submenu = _react2.default.createElement(
_semanticUiReact.Segment,
{ attached: 'bottom', className: 'shapes-selected-menu' },
_react2.default.createElement(
_semanticUiReact.Form,
{ size: 'small', style: { padding: 5 }, as: 'none' },
_react2.default.createElement(
_semanticUiReact.Form.Group,
{ widths: 'equal' },
fillEditable ? _react2.default.createElement(
_semanticUiReact.Form.Field,
null,
_react2.default.createElement(_colorPickerModal2.default, { color: this.props.selectedStyle.fill,
setShapeStyle: this.props.setShapeStyle, desc: 'Fill', attr: 'fill' })
) : null,
_react2.default.createElement(
_semanticUiReact.Form.Field,
null,
_react2.default.createElement(_colorPickerModal2.default, { color: this.props.selectedStyle.stroke, setShapeStyle: this.props.setShapeStyle, desc: 'Stroke', attr: 'stroke' })
)
),
_react2.default.createElement(
_semanticUiReact.Form.Group,
{ widths: '10' },
_react2.default.createElement(_semanticUiReact.Form.Field, { width: '10', control: _numberPicker2.default, label: 'Stroke-Width',
name: "strokeWidthPicker",
value: this.props.selectedStyle.strokeWidth ? this.props.selectedStyle.strokeWidth : 0,
onChange: this.handleStrokeWidthChange,
min: 0 })
)
)
);
} else if (activeItem === 'text') {
submenu = _react2.default.createElement(
_semanticUiReact.Segment,
{ attached: 'bottom', className: 'shapes-selected-menu' },
_react2.default.createElement(
_semanticUiReact.Form,
{ size: 'small', style: { padding: 5 }, as: 'none' },
_react2.default.createElement(
_semanticUiReact.Form.Group,
{ widths: 'equal' },
_react2.default.createElement(
_semanticUiReact.Form.Field,
null,
_react2.default.createElement(_colorPickerModal2.default, { color: this.props.selectedStyle.color, setShapeStyle: this.props.setShapeStyle, desc: 'Color', attr: 'color' })
)
),
_react2.default.createElement(
_semanticUiReact.Form.Group,
{ widths: '10' },
_react2.default.createElement(_semanticUiReact.Form.Field, { width: '10', control: _numberPicker2.default, label: 'Font-Size',
name: "fontSizePicker",
value: this.props.selectedStyle.fontSize ? this.props.selectedStyle.fontSize : 0,
onChange: this.handleFontSizeChange,
min: 0 })
)
)
);
} else if (activeItem === 'dimension') {
(function () {
var x = selectedShape.position.x;
var y = selectedShape.position.y;
var width = selectedShape.dims.width + selectedShape.deltaDims.width;
var height = selectedShape.dims.height + selectedShape.deltaDims.height;
submenu = _react2.default.createElement(
_semanticUiReact.Segment,
{ attached: 'bottom', className: 'shapes-selected-menu' },
_react2.default.createElement(
_semanticUiReact.Form,
{ size: 'small', style: { padding: 5 } },
_react2.default.createElement(
_semanticUiReact.Form.Group,
{ widths: 6 },
_react2.default.createElement(_semanticUiReact.Form.Input, { label: 'X', type: 'number', value: x, onChange: function onChange(e, f) {
return _this2.handlePositionChange('x', f.value - x);
} }),
_react2.default.createElement(_semanticUiReact.Form.Input, { label: 'Y', type: 'number', value: y, onChange: function onChange(e, f) {
return _this2.handlePositionChange('y', f.value - y);
} })
),
_react2.default.createElement(
_semanticUiReact.Form.Group,
{ widths: 6 },
_react2.default.createElement(_semanticUiReact.Form.Input, { label: 'Width', name: 'width', type: 'number', value: width, onChange: function onChange(e, f) {
return _this2.handleDimChange('width', f.value - width);
} }),
_react2.default.createElement(_semanticUiReact.Form.Input, { label: 'Height', name: 'height', type: 'number', value: height, onChange: function onChange(e, f) {
return _this2.handleDimChange('height', f.value - height);
} })
)
)
);
})();
}
menu = _react2.default.createElement(
'div',
{ id: 'right-sidebar', style: style },
_react2.default.createElement(
_semanticUiReact.Menu,
{ attached: 'top', tabular: true },
modelEditable ? _react2.default.createElement(_semanticUiReact.Menu.Item, { name: 'model', active: activeItem === 'model', onClick: this.handleTabClick }) : null,
styleEditable ? _react2.default.createElement(_semanticUiReact.Menu.Item, { name: 'style', active: activeItem === 'style', onClick: this.handleTabClick }) : null,
textEditable ? _react2.default.createElement(_semanticUiReact.Menu.Item, { name: 'text', active: activeItem === 'text', onClick: this.handleTabClick }) : null,
this.props.selectedShapes.length == 1 ? _react2.default.createElement(_semanticUiReact.Menu.Item, { name: 'dims', active: activeItem === 'dims', onClick: this.handleTabClick }) : null
),
submenu
);
}
return this.props.rightSideBarPresent ? menu : null;
}
}]);
return RightSideBarMenu;
}(_react.Component);
var mapStateToProps = function mapStateToProps(_ref2) {
var shapeCollection = _ref2.shapeCollection;
return {
selectedShapes: shapeCollection.present.selectedShapes,
shapes: shapeCollection.present.shapes,
selectedStyle: shapeCollection.present.selectedStyle,
dataHeaders: shapeCollection.present.dataHeaders,
data: shapeCollection.present.data,
rightSideBarWidth: shapeCollection.present.layout.rightSideBarWidth,
rightSideBarPresent: shapeCollection.present.layout.rightSideBarPresent,
overview: shapeCollection.present.overview,
diagramWidth: shapeCollection.present.layout.diagramWidth,
diagramHeight: shapeCollection.present.layout.diagramHeight
};
};
var mapDispatchToProps = {
setShapeStyle: _actions.setShapeStyle,
setShapeModel: _actions.setShapeModel,
setOverview: _actions.setOverview,
setLayout: _actions.setLayout,
resizeShapes: _actions.resizeShapes
};
exports.default = (0, _reactRedux.connect)(mapStateToProps, mapDispatchToProps)(RightSideBarMenu);
| 31,269
|
https://github.com/mtlgreen/mtlgreen.com/blob/master/src/components/EventCardList/EventCardList.js
|
Github Open Source
|
Open Source
|
MIT
| null |
mtlgreen.com
|
mtlgreen
|
JavaScript
|
Code
| 66
| 257
|
import React, { Component } from 'react'
import EventCard from '../EventCard/EventCard'
import './eventCardList.scss'
class EventCardList extends Component {
renderEventCard = node => {
return (
<EventCard
thumbnail={node.frontmatter.thumbnail.childImageSharp.sizes}
title={node.frontmatter.title}
slug={node.fields.slug}
date={node.frontmatter.date}
shortDescription={node.frontmatter.shortDescription}
screenWidth={this.props.screenWidth}
/>
)
}
render() {
let dataArray = this.props.dataArray
return (
<div>
{dataArray.map(({ node }, index) => {
return (
<div key={index} className="event-card-list__container">
{this.renderEventCard(node)}
</div>
)
})}
</div>
)
}
}
export default EventCardList
| 11,385
|
https://github.com/Cyecize/Can-Sealers-Bulgaria/blob/master/templates/partials/sidebar/similar-products.html.twig
|
Github Open Source
|
Open Source
|
MIT
| 2,020
|
Can-Sealers-Bulgaria
|
Cyecize
|
Twig
|
Code
| 27
| 90
|
<div class="sidebar-section pt-2">
<p class="text-dark font-weight-bold">{{ categoryName }}:</p>
{% for product in products %}
{% embed 'products/partials/small-product-card.html.twig' with {'product':product} %} {% endembed %}
{% endfor %}
</div>
| 45,788
|
https://github.com/apottere/gradle/blob/master/subprojects/core/src/main/java/org/gradle/api/internal/tasks/TaskStatistics.java
|
Github Open Source
|
Open Source
|
Apache-2.0
| null |
gradle
|
apottere
|
Java
|
Code
| 321
| 870
|
/*
* Copyright 2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.gradle.api.internal.tasks;
import com.google.common.collect.Maps;
import org.gradle.api.logging.Logger;
import org.gradle.api.logging.Logging;
import org.gradle.internal.IoActions;
import java.io.Closeable;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
public class TaskStatistics implements Closeable {
private final static Logger LOGGER = Logging.getLogger(TaskStatistics.class);
private final static String TASK_STATISTICS_PROPERTY = "org.gradle.internal.tasks.stats";
private final AtomicInteger eagerTasks = new AtomicInteger();
private final AtomicInteger lazyTasks = new AtomicInteger();
private final AtomicInteger lazyRealizedTasks = new AtomicInteger();
private final Map<Class, Integer> typeCounts = Maps.newHashMap();
private final boolean collectStatistics;
private PrintWriter lazyTaskLog;
public TaskStatistics() {
String taskStatistics = System.getProperty(TASK_STATISTICS_PROPERTY);
if (taskStatistics!=null) {
collectStatistics = true;
if (!taskStatistics.isEmpty()) {
try {
lazyTaskLog = new PrintWriter(new FileWriter(taskStatistics));
} catch (IOException e) {
// don't care
}
}
} else {
collectStatistics = false;
}
}
public void eagerTask(Class<?> type) {
if (collectStatistics) {
eagerTasks.incrementAndGet();
synchronized (typeCounts) {
Integer count = typeCounts.get(type);
if (count == null) {
count = 1;
} else {
count = count + 1;
}
typeCounts.put(type, count);
}
}
}
public void lazyTask() {
if (collectStatistics) {
lazyTasks.incrementAndGet();
}
}
public void lazyTaskRealized() {
if (collectStatistics) {
lazyRealizedTasks.incrementAndGet();
if (lazyTaskLog != null) {
new Throwable().printStackTrace(lazyTaskLog);
}
}
}
@Override
public void close() throws IOException {
if (collectStatistics) {
LOGGER.lifecycle("E {} L {} LR {}", eagerTasks.getAndSet(0), lazyTasks.getAndSet(0), lazyRealizedTasks.getAndSet(0));
for (Map.Entry<Class, Integer> typeCount : typeCounts.entrySet()) {
LOGGER.lifecycle(typeCount.getKey() + " " + typeCount.getValue());
}
IoActions.closeQuietly(lazyTaskLog);
}
}
}
| 3,279
|
https://github.com/599259501/gfast-ui/blob/master/src/views/system/wf/flow/list/index.vue
|
Github Open Source
|
Open Source
|
MIT
| 2,021
|
gfast-ui
|
599259501
|
Vue
|
Code
| 742
| 3,598
|
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="流程类别" prop="type">
<el-select v-model="queryParams.type" placeholder="请选择流程类别" clearable size="small">
<el-option
v-for="dict in typeOptions"
:key="dict.key"
:label="dict.value"
:value="dict.key"
/>
</el-select>
</el-form-item>
<el-form-item label="流程名称" prop="flow_name">
<el-input
v-model="queryParams.flow_name"
placeholder="请输入流程名称"
clearable
size="small"
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<el-form-item label="状态" prop="status">
<el-select v-model="queryParams.status" placeholder="请选择状态" clearable size="small">
<el-option
v-for="dict in statusOptions"
:key="dict.key"
:label="dict.value"
:value="dict.key"
/>
</el-select>
</el-form-item>
<el-form-item>
<el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
</el-form-item>
</el-form>
<el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
icon="el-icon-plus"
size="mini"
@click="handleAdd"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
>删除</el-button>
</el-col>
</el-row>
<el-table v-loading="loading" :data="flowList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="流程ID" align="center" prop="id" />
<el-table-column label="流程类别" align="center" prop="type" :formatter="typeFormat" />
<el-table-column label="流程名称" align="center" prop="flow_name" />
<el-table-column label="状态" align="center" prop="status" :formatter="statusFormat" />
<el-table-column label="状态" align="center">
<template slot-scope="scope">
<el-switch
v-model="scope.row.status"
:active-value="1"
:inactive-value="0"
@change="handleStatusChange(scope.row)"
></el-switch>
</template>
</el-table-column>
<el-table-column label="添加时间" align="center" prop="add_time" >
<template slot-scope="scope">
<span>{{ parseTime(scope.row.add_time) }}</span>
</template>
</el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<template v-if="!scope.row.running">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-magic-stick"
@click="handleDesign(scope.row)"
>流程设计</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
>删除</el-button>
</template>
<template v-else>
<el-tag type="danger">流程中</el-tag>
</template>
</template>
</el-table-column>
</el-table>
<pagination
v-show="total>0"
:total="total"
:page.sync="queryParams.pageNum"
:limit.sync="queryParams.pageSize"
@pagination="getList"
/>
<!-- 添加或修改工作流对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="流程类别">
<el-select v-model="form.type" placeholder="请选择流程类别">
<el-option
v-for="dict in typeOptions"
:key="dict.key"
:label="dict.value"
:value="dict.key"
></el-option>
</el-select>
</el-form-item>
<el-form-item label="流程名称" prop="flow_name">
<el-input v-model="form.flow_name" placeholder="请输入流程名称" />
</el-form-item>
<el-form-item label="描述" prop="flow_desc">
<el-input v-model="form.flow_desc" placeholder="请输入描述" />
</el-form-item>
<el-form-item label="排序" prop="sort_order">
<el-input v-model="form.sort_order" placeholder="请输入排序" />
</el-form-item>
<el-form-item label="状态">
<el-radio-group v-model="form.status">
<el-radio
v-for="dict in statusOptions"
:key="dict.key"
:label="parseInt(dict.key)"
>{{dict.value}}</el-radio>
</el-radio-group>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm">确 定</el-button>
<el-button @click="cancel">取 消</el-button>
</div>
</el-dialog>
</div>
</template>
<script>
import { listFlow, getFlow, delFlow, addFlow, updateFlow,statusSetFlow} from '@/api/system/flow/flow'
import {start, stop} from "@/api/monitor/job";
export default {
name: "flow",
data() {
return {
// 遮罩层
loading: true,
// 选中数组
ids: [],
// 非单个禁用
single: true,
// 非多个禁用
multiple: true,
// 显示搜索条件
showSearch: true,
// 总条数
total: 0,
// 工作流表格数据
flowList: [],
// 弹出层标题
title: "",
// 是否显示弹出层
open: false,
// $comment字典
typeOptions: [],
// $comment字典
statusOptions: [],
// 查询参数
queryParams: {
pageNum: 1,
pageSize: 10,
type: null,
flow_name: null,
status: null,
},
// 表单参数
form: {},
// 表单校验
rules: {
flow_name: [
{ required: true, message: "流程名称不能为空", trigger: "blur" }
],
status: [
{ required: true, message: "状态不能为空", trigger: "blur" }
],
}
};
},
created() {
this.getList();
this.getDicts("flow_type").then(response => {
this.typeOptions = response.data.values || [];
});
this.getDicts("sys_normal_disable").then(response => {
this.statusOptions = response.data.values || [];
});
},
methods: {
/** 查询工作流列表 */
getList() {
this.loading = true;
listFlow(this.queryParams).then(response => {
this.flowList = response.data.list;
this.total = response.data.total;
this.loading = false;
});
},
// $comment字典翻译
typeFormat(row, column) {
return this.selectDictLabel(this.typeOptions, row.type);
},
// $comment字典翻译
statusFormat(row, column) {
return this.selectDictLabel(this.statusOptions, row.status);
},
// 取消按钮
cancel() {
this.open = false;
this.reset();
},
// 表单重置
reset() {
this.form = {
id: null,
type: null,
flow_name: null,
flow_desc: null,
sort_order: null,
status: 0 ,
is_del: null,
uid: null,
add_time: null
};
this.resetForm("form");
},
/** 搜索按钮操作 */
handleQuery() {
this.queryParams.pageNum = 1;
this.getList();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
this.handleQuery();
},
// 多选框选中数据
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset();
this.open = true;
this.title = "添加工作流";
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset();
const id = row.id || this.ids
getFlow(id).then(response => {
this.form = response.data;
this.open = true;
this.title = "修改工作流";
});
},
handleDesign(row){
const id = row.id || this.ids[0];
this.$router.push({ path: "/system/wf/flow/design", query: {id:id}});
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.id != null) {
updateFlow(this.form).then(response => {
if (response.code === 0) {
this.msgSuccess("修改成功");
this.open = false;
this.getList();
}
});
} else {
addFlow(this.form).then(response => {
if (response.code === 0) {
this.msgSuccess("新增成功");
this.open = false;
this.getList();
}
});
}
}
});
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids;
this.$confirm('是否确认删除工作流编号为"' + ids + '"的数据项?', "警告", {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}).then(function() {
return delFlow(ids);
}).then(() => {
this.getList();
this.msgSuccess("删除成功");
}).catch(function() {});
},
// 状态修改
handleStatusChange(row) {
let text = row.status === 1 ? "启用" : "停用";
this.$confirm(
'确认要"' + text + '""' + row.flow_name + '"吗?',
"警告",
{
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning"
}
).then(function() {
if(row.status === 1){
return statusSetFlow({id:row.id,status:1});
} else {
return statusSetFlow({id:row.id,status:0});
}
}).then(() => {
this.msgSuccess(text + "成功");
}).catch(function() {
row.status = row.status === 0 ? 1 : 0;
});
},
} //methods结束
};
</script>
| 21,358
|
https://github.com/ubc/iPeer/blob/master/app/plugins/cake_djjob/vendors/shells/worker.php
|
Github Open Source
|
Open Source
|
MIT
| 2,023
|
iPeer
|
ubc
|
PHP
|
Code
| 785
| 2,503
|
<?php
// based on: https://github.com/josegonzalez/cakephp-cake-djjob/tree/1.3
// updated to php 7
if (!class_exists('ConnectionManager')) {
App::import('Model', 'ConnectionManager');
}
if (!class_exists('CakeJob')) {
App::import('Lib', 'CakeDjjob.cake_job', array(
'file' => 'jobs' . DS . 'cake_job.php',
));
}
if (!class_exists('DJJob')) {
App::import('Vendor', 'Djjob.DJJob', array(
'file' => 'DJJob.php',
));
}
/**
* Uses _ (underscore) to denote plugins, since php classnames
* cannot use periods, and the unserialize_jobs method
*
* @package default
* @author Jose Diaz-Gonzalez
*/
function unserialize_jobs($className) {
$plugin = null;
if (strstr($className, '_')) {
list($plugin, $className) = explode('_', $className);
}
if (empty($className)) {
$className = $plugin;
$plugin = null;
}
if (!empty($plugin)) {
$plugin = $plugin . '.';
}
App::import('Lib', $plugin . 'jobs/' . Inflector::underscore($className));
}
/**
* Worker runs jobs created by the DJJob system.
*
* @package job_workers
*/
class WorkerShell extends Shell {
var $settings = array(
'connection'=> 'default',
'type' => 'mysql',
);
var $_queue = 'default';
var $_count = 0;
var $_sleep = 5;
var $_max = 5;
var $_debug = 0;
var $_action = 0;
var $_column = 0;
var $_date = null;
var $_save = true;
/**
* Override initialize
*
* @access public
*/
function initialize() {
$this->_welcome();
$this->out('Jobs Worker Shell');
$this->hr();
}
/**
* Override startup
*
* @access public
*/
function startup() {
if (!empty($this->params['queue'])) {
$this->_queue = $this->params['queue'];
}
if (!empty($this->params['count'])) {
$this->_count = $this->params['count'];
}
if (!empty($this->params['sleep'])) {
$this->_sleep = $this->params['sleep'];
}
if (!empty($this->params['max'])) {
$this->_max = $this->params['max'];
}
if (!empty($this->params['debug'])) {
if ($this->params['debug'] == 'false') {
$this->params['debug'] = 0;
}
if ($this->params['debug'] == 'true') {
$this->params['debug'] = 1;
}
$this->_debug = (int) $this->params['debug'];
}
if (!empty($this->params['save'])) {
if ($this->params['save'] == 'false') {
$this->params['save'] = 0;
}
if ($this->params['save'] == 'true') {
$this->params['save'] = 1;
}
$this->_save = (int) $this->params['save'];
}
if (!empty($this->params['connection'])) {
$this->settings['connection'] = $this->params['connection'];
}
if (!empty($this->params['type'])) {
$this->settings['type'] = $this->params['type'];
}
if (!empty($this->params['action'])) {
if (!in_array($this->params['action'], array('clean', 'unlock'))) {
$this->cakeError('error', array(array(
'code' => '', 'name' => '',
'message' => 'Invalid action ' . $this->params['action']
)));
}
$this->_action = $this->params['action'];
if ($this->_action == 'clean') {
$this->_column = 'failed_at';
} elseif ($this->_action == 'unlock') {
$this->_column = 'locked_at';
}
}
if (empty($this->params['date'])) {
$this->_date = date('Y-m-d H:i:s');
} else {
$this->_date = date('Y-m-d H:i:s', strtotime($this->params['date']));
}
ini_set('unserialize_callback_func', 'unserialize_jobs');
$connection = ConnectionManager::getDataSource('default');
DJJob::configure([
'driver' => 'mysql',
'host' => $connection->config['host'],
'dbname' => $connection->config['database'],
'port' => $connection->config['port'],
'user' => $connection->config['login'],
'password' => $connection->config['password'],
]);
}
/**
* Override main
*
* @access public
*/
function main() {
$this->help();
}
function run() {
Configure::write('debug', $this->_debug);
if (empty($this->_queue)) {
$this->cakeError('error', array(array(
'code' => '', 'name' => '',
'message' => 'No queue set'
)));
}
$worker = new DJWorker(array(
"queue" => $this->_queue,
"count" => $this->_count,
"sleep" => $this->_sleep,
"max_attempts" => $this->_max,
));
$worker->start();
}
function status() {
Configure::write('debug', $this->_debug);
if (empty($this->_queue)) {
$this->cakeError('error', array(array(
'code' => '', 'name' => '',
'message' => 'No queue set'
)));
}
$status = DJJob::status($this->_queue);
foreach ($status as $name => $count) {
$this->out(sprintf("%s Jobs: %d", Inflector::humanize($name), $count));
}
}
function cleanup() {
Configure::write('debug', $this->_debug);
if (empty($this->_column)) {
$this->cakeError('error', array(array(
'code' => '', 'name' => '',
'message' => 'No column to filter by is set'
)));
}
$conditions = array(
$this->_column . ' <=' => $this->_date,
'not' => array($this->_column => null),
);
if (!empty($this->_queue)) {
$conditions['Job.queue'] = $this->_queue;
}
$JobModel = ClassRegistry::init('Job');
$jobs = $JobModel->find('all', array('conditions' => $conditions));
foreach ($jobs as $job) {
switch ($this->_action) {
case 'unlock':
$job['Job']['locked_at'] = null;
$job['Job']['locked_by'] = null;
$JobModel->save($job);
if ($this->_save) $JobModel->save($job);
break;
case 'clean':
if ($this->_save) $JobModel->delete($job['Job']['id']);
break;
}
}
$this->out(sprintf('%d %s%s', count($jobs), ($this->_save)? '':'not', " {$this->_action}ed\n"));
}
/**
* Displays help contents
*
* @access public
*/
function help() {
$help = <<<TEXT
The Worker Shell runs jobs created by the DJJob system.
---------------------------------------------------------------
Usage: cake worker <command> <arg1> <arg2>...
---------------------------------------------------------------
Global Params:
-connection <config>
set db config <config>.
default config: 'default'
-type <name>
pdo name for connection <type>.
default type: 'mysql'
-debug <boolean>
set debug level dynamically for running jobs
default value: {$this->_debug}
valid values: true, false, 0, 1, 2
-queue <name>
queue <name> to pull jobs from.
default queue: {$this->_queue}
Run Params:
-count <number>
run <number> of jobs to run before exiting (0 for unlimited).
default count: {$this->_count}
-sleep <name>
sleep <number> seconds after finding no new jobs.
default seconds: {$this->_sleep}
-max <number>
max <number> of retries for a given job.
default retries: {$this->_max}
Clean Params:
-action <string>
action to perform on cleanup task
default value: null
valid values: clean, unlock
-date <string>
date offset
default value: {$this->_date}
-save <boolean>
allow cleanup to modify database
default value: {$this->_save}
valid values: true, false, 0, 1
Commands:
worker help
shows this help message.
worker run
runs jobs in the system
worker status
returns the status of a job queue
worker cleanup
cleans a job queue
TEXT;
$this->out($help);
$this->_stop();
}
}
| 33,839
|
https://github.com/d18zj/Exceptionless.Net/blob/master/src/Exceptionless/Extensions/ExceptionExtensions.cs
|
Github Open Source
|
Open Source
|
Apache-2.0
| 2,022
|
Exceptionless.Net
|
d18zj
|
C#
|
Code
| 339
| 929
|
using System;
using System.Linq;
using System.Reflection;
using Exceptionless.Models;
using Exceptionless.Plugins;
namespace Exceptionless {
public static class ExceptionExtensions {
/// <summary>
/// Creates a builder object for constructing error reports in a fluent api.
/// </summary>
/// <param name="exception">The exception.</param>
/// <param name="pluginContextData">
/// Any contextual data objects to be used by Exceptionless plugins to gather default
/// information for inclusion in the report information.
/// </param>
/// <param name="client">
/// The ExceptionlessClient instance used for configuration. If a client is not specified, it will use
/// ExceptionlessClient.Default.
/// </param>
/// <returns></returns>
public static EventBuilder ToExceptionless(this Exception exception, ContextData pluginContextData = null, ExceptionlessClient client = null) {
if (client == null)
client = ExceptionlessClient.Default;
if (pluginContextData == null)
pluginContextData = new ContextData();
pluginContextData.SetException(exception);
return client.CreateEvent(pluginContextData).SetType(Event.KnownTypes.Error);
}
/// <summary>
/// Creates a builder object for constructing error reports in a fluent api.
/// </summary>
/// <param name="exception">The exception.</param>
/// <param name="client">
/// The ExceptionlessClient instance used for configuration.
/// </param>
/// <returns></returns>
public static EventBuilder ToExceptionless(this Exception exception, ExceptionlessClient client) {
if (client == null)
throw new ArgumentNullException(nameof(client));
var pluginContextData = new ContextData();
pluginContextData.SetException(exception);
return client.CreateEvent(pluginContextData).SetType(Event.KnownTypes.Error);
}
}
}
namespace Exceptionless.Extensions {
public static class ExceptionExtensions {
public static Exception GetInnermostException(this Exception exception) {
if (exception == null)
return null;
Exception current = exception;
while (current.InnerException != null)
current = current.InnerException;
return current;
}
public static string GetMessage(this Exception exception) {
if (exception == null)
return String.Empty;
var aggregateException = exception as AggregateException;
if (aggregateException != null)
return String.Join(Environment.NewLine, aggregateException.Flatten().InnerExceptions.Where(ex => !String.IsNullOrEmpty(ex.GetInnermostException().Message)).Select(ex => ex.GetInnermostException().Message));
return exception.GetInnermostException().Message;
}
private static readonly string _marker = "@exceptionless";
public static void MarkProcessed(this Exception exception) {
if (exception == null)
return;
try {
if (exception.Data != null) {
var genericTypes = exception.Data.GetType().GetGenericArguments();
if (genericTypes.Length == 0 || genericTypes[0].GetTypeInfo().IsAssignableFrom(typeof(string).GetTypeInfo()))
exception.Data[_marker] = genericTypes.Length > 0 ? genericTypes[1].GetDefaultValue() : null;
}
} catch (Exception) {}
MarkProcessed(exception.InnerException);
}
public static bool IsProcessed(this Exception exception) {
if (exception == null)
return false;
try {
if (exception.Data != null && exception.Data.Contains(_marker))
return true;
} catch (Exception) {}
return IsProcessed(exception.InnerException);
}
}
}
| 49,422
|
https://github.com/evdcush/neorl/blob/master/neorl/tests/test_fneat.py
|
Github Open Source
|
Open Source
|
MIT
| 2,022
|
neorl
|
evdcush
|
Python
|
Code
| 85
| 343
|
from neorl import FNEAT
import numpy as np
def test_fneat():
def Sphere(individual):
"""Sphere test objective function.
F(x) = sum_{i=1}^d xi^2
d=1,2,3,...
Range: [-100,100]
Minima: 0
"""
return sum(x**2 for x in individual)
nx=5
lb=-100
ub=100
bounds={}
for i in range(1,nx+1):
bounds['x'+str(i)]=['float', -100, 100]
# modify your own NEAT config
config = {
'pop_size': 50,
'num_hidden': 1,
'activation_mutate_rate': 0.1,
'survival_threshold': 0.3,
}
fneat=FNEAT(fit=Sphere, bounds=bounds, mode='min', config= config, ncores=1, seed=1)
#some random guess (just one individual)
x0 = np.random.uniform(lb,ub,nx)
x_best, y_best, fneat_hist=fneat.evolute(ngen=5, x0=x0, verbose=True,
checkpoint_itv=None, startpoint=None)
test_fneat()
| 7,758
|
https://github.com/briancappello/flask-unchained/blob/master/flask_unchained/bundles/api/model_resource.py
|
Github Open Source
|
Open Source
|
MIT
| 2,022
|
flask-unchained
|
briancappello
|
Python
|
Code
| 1,620
| 5,173
|
import inspect
from typing import *
from flask import current_app, make_response, request
from flask_unchained import Resource, route, param_converter, unchained, injectable
from flask_unchained.string_utils import kebab_case, pluralize
from flask_unchained.bundles.controller.attr_constants import (
CONTROLLER_ROUTES_ATTR, FN_ROUTES_ATTR)
from flask_unchained.bundles.controller.constants import (
ALL_RESOURCE_METHODS, RESOURCE_INDEX_METHODS, RESOURCE_MEMBER_METHODS,
CREATE, DELETE, GET, LIST, PATCH, PUT)
from flask_unchained.bundles.controller.resource import (
ResourceMetaclass, ResourceMetaOptionsFactory, ResourceUrlPrefixMetaOption)
from flask_unchained.bundles.controller.route import Route
from flask_unchained.bundles.controller.utils import get_param_tuples
from flask_unchained.bundles.sqlalchemy import SessionManager
from flask_unchained.bundles.sqlalchemy.meta_options import ModelMetaOption
from functools import partial
from http import HTTPStatus
from py_meta_utils import McsArgs, MetaOption, _missing
from werkzeug.wrappers import Response
from .decorators import list_loader, patch_loader, put_loader, post_loader
from .model_serializer import ModelSerializer
from .utils import unpack
class ModelResourceMetaclass(ResourceMetaclass):
def __new__(mcs, name, bases, clsdict):
mcs_args = McsArgs(mcs, name, bases, clsdict)
cls = super().__new__(*mcs_args)
if mcs_args.is_abstract:
return cls
routes: Dict[str, List[Route]] = getattr(cls, CONTROLLER_ROUTES_ATTR)
include_methods = set(cls.Meta.include_methods)
exclude_methods = set(cls.Meta.exclude_methods)
for method_name in ALL_RESOURCE_METHODS:
if (method_name in exclude_methods
or method_name not in include_methods):
routes.pop(method_name, None)
continue
route: Route = getattr(clsdict.get(method_name), FN_ROUTES_ATTR, [None])[0]
if not route:
route = Route(None, mcs_args.getattr(method_name))
if method_name in RESOURCE_INDEX_METHODS:
rule = '/'
else:
rule = cls.Meta.member_param
route.rule = rule
routes[method_name] = [route]
setattr(cls, CONTROLLER_ROUTES_ATTR, routes)
return cls
class ModelResourceSerializerMetaOption(MetaOption):
"""
The serializer instance to use. If left unspecified, it will be looked up by
model name and automatically assigned.
"""
def __init__(self):
super().__init__('serializer', default=None, inherit=True)
def check_value(self,
value,
mcs_args: McsArgs, # skipcq: PYL-W0613 (unused arg)
) -> None:
if not value or isinstance(value, ModelSerializer) or (
isinstance(value, type) and issubclass(value, ModelSerializer)
):
return
raise ValueError(f'The {self.name} meta option must be a subclass or '
f'instance of ModelSerializer')
class ModelResourceSerializerCreateMetaOption(MetaOption):
"""
The serializer instance to use for creating models. If left unspecified, it
will be looked up by model name and automatically assigned.
"""
def __init__(self):
super().__init__('serializer_create', default=None, inherit=True)
def check_value(self,
value,
mcs_args: McsArgs, # skipcq: PYL-W0613 (unused arg)
) -> None:
if not value or isinstance(value, ModelSerializer) or (
isinstance(value, type) and issubclass(value, ModelSerializer)
):
return
raise ValueError(f'The {self.name} meta option must be a subclass or '
f'instance of ModelSerializer')
class ModelResourceSerializerManyMetaOption(MetaOption):
"""
The serializer instance to use for listing models. If left unspecified, it
will be looked up by model name and automatically assigned.
"""
def __init__(self):
super().__init__('serializer_many', default=None, inherit=True)
def check_value(self,
value,
mcs_args: McsArgs, # skipcq: PYL-W0613 (unused arg)
) -> None:
if not value or isinstance(value, ModelSerializer) or (
isinstance(value, type) and issubclass(value, ModelSerializer)
):
return
raise ValueError(f'The {self.name} meta option must be a subclass or '
f'instance of ModelSerializer')
class ModelResourceIncludeMethodsMetaOption(MetaOption):
"""
A list of resource methods to automatically include. Defaults to
``('list', 'create', 'get', 'patch', 'put', 'delete')``.
"""
def __init__(self):
super().__init__('include_methods', default=_missing, inherit=True)
def get_value(self, meta, base_classes_meta, mcs_args: McsArgs):
value = super().get_value(meta, base_classes_meta, mcs_args)
if value is not _missing:
return value
return ALL_RESOURCE_METHODS
def check_value(self,
value,
mcs_args: McsArgs, # skipcq: PYL-W0613 (unused arg)
) -> None:
if not value:
return
if not all(x in ALL_RESOURCE_METHODS for x in value):
raise ValueError(f'Invalid values for the {self.name} meta option. The '
f'valid values are ' + ', '.join(ALL_RESOURCE_METHODS))
class ModelResourceExcludeMethodsMetaOption(MetaOption):
"""
A list of resource methods to exclude. Defaults to ``()``.
"""
def __init__(self):
super().__init__('exclude_methods', default=(), inherit=True)
def check_value(self,
value,
mcs_args: McsArgs, # skipcq: PYL-W0613 (unused arg)
) -> None:
if not value:
return
if not all(x in ALL_RESOURCE_METHODS for x in value):
raise ValueError(f'Invalid values for the {self.name} meta option. The '
f'valid values are ' + ', '.join(ALL_RESOURCE_METHODS))
class ModelResourceIncludeDecoratorsMetaOption(MetaOption):
"""
A list of resource methods for which to automatically apply the default decorators.
Defaults to ``('list', 'create', 'get', 'patch', 'put', 'delete')``.
.. list-table::
:widths: 10 30
:header-rows: 1
* - Method Name
- Decorator(s)
* - list
- :func:`~flask_unchained.bundles.api.decorators.list_loader`
* - create
- :func:`~flask_unchained.bundles.api.decorators.post_loader`
* - get
- :func:`~flask_unchained.decorators.param_converter`
* - patch
- :func:`~flask_unchained.decorators.param_converter`,
:func:`~flask_unchained.bundles.api.decorators.patch_loader`
* - put
- :func:`~flask_unchained.decorators.param_converter`,
:func:`~flask_unchained.bundles.api.decorators.put_loader`
* - delete
- :func:`~flask_unchained.decorators.param_converter`
"""
def __init__(self):
super().__init__('include_decorators', default=_missing, inherit=True)
def get_value(self, meta, base_classes_meta, mcs_args: McsArgs):
value = super().get_value(meta, base_classes_meta, mcs_args)
if value is not _missing:
return value
return ALL_RESOURCE_METHODS
def check_value(self,
value,
mcs_args: McsArgs, # skipcq: PYL-W0613 (unused arg)
) -> None:
if not value:
return
if not all(x in ALL_RESOURCE_METHODS for x in value):
raise ValueError(f'Invalid values for the {self.name} meta option. The '
f'valid values are ' + ', '.join(ALL_RESOURCE_METHODS))
class ModelResourceExcludeDecoratorsMetaOption(MetaOption):
"""
A list of resource methods for which to *not* apply the default decorators, as
outlined in :attr:`include_decorators`. Defaults to ``()``.
"""
def __init__(self):
super().__init__('exclude_decorators', default=(), inherit=True)
def check_value(self,
value,
mcs_args: McsArgs, # skipcq: PYL-W0613 (unused arg)
) -> None:
if not value:
return
if not all(x in ALL_RESOURCE_METHODS for x in value):
raise ValueError(f'Invalid values for the {self.name} meta option. The '
f'valid values are ' + ', '.join(ALL_RESOURCE_METHODS))
class ModelResourceMethodDecoratorsMetaOption(MetaOption):
"""
This can either be a list of decorators to apply to *all* methods, or a
dictionary of method names to a list of decorators to apply for each method.
In both cases, decorators specified here are run *before* the default
decorators.
"""
def __init__(self):
super().__init__('method_decorators', default=(), inherit=True)
def check_value(self, value, mcs_args: McsArgs):
if not value:
return
if isinstance(value, (list, tuple)):
if not all(callable(x) for x in value):
raise ValueError(f'The {self.name} meta option requires a '
f'list or tuple of callables')
else:
for method_name, decorators in value.items():
if not mcs_args.getattr(method_name):
raise ValueError(
f'The {method_name} was not found on {mcs_args.name}')
if not all(callable(x) for x in decorators):
raise ValueError(f'Invalid decorator detected in the {self.name} '
f'meta option for the {method_name} key')
class ModelResourceUrlPrefixMetaOption(MetaOption):
"""
The url prefix to use for all routes from this resource. Defaults to the
pluralized and snake_cased model class name.
"""
def __init__(self):
super().__init__('url_prefix', default=_missing, inherit=False)
def get_value(self, meta, base_classes_meta, mcs_args: McsArgs):
value = super().get_value(meta, base_classes_meta, mcs_args)
if (value is not _missing
or mcs_args.Meta.abstract
or not mcs_args.Meta.model):
return value
return '/' + pluralize(kebab_case(mcs_args.Meta.model.__name__))
def check_value(self,
value,
mcs_args: McsArgs, # skipcq: PYL-W0613 (unused arg)
) -> None:
if not value:
return
if not isinstance(value, str):
raise ValueError(f'The {self.name} meta option must be a string')
class ModelResourceMetaOptionsFactory(ResourceMetaOptionsFactory):
_allowed_properties = ['model']
_options = [option for option in ResourceMetaOptionsFactory._options
if not issubclass(option, ResourceUrlPrefixMetaOption)] + [
ModelMetaOption,
ModelResourceUrlPrefixMetaOption, # must come after the model meta option
ModelResourceSerializerMetaOption,
ModelResourceSerializerCreateMetaOption,
ModelResourceSerializerManyMetaOption,
ModelResourceIncludeMethodsMetaOption,
ModelResourceExcludeMethodsMetaOption,
ModelResourceIncludeDecoratorsMetaOption,
ModelResourceExcludeDecoratorsMetaOption,
ModelResourceMethodDecoratorsMetaOption,
]
def __init__(self):
super().__init__()
self._model = None
@property
def model(self):
# make sure to always return the correct mapped model class
if not unchained._models_initialized or not self._model:
return self._model
return unchained.sqlalchemy_bundle.models[self._model.__name__]
@model.setter
def model(self, model):
self._model = model
class ModelResource(Resource, metaclass=ModelResourceMetaclass):
"""
Base class for model resources. This is intended for building RESTful APIs
with SQLAlchemy models and Marshmallow serializers.
"""
_meta_options_factory_class = ModelResourceMetaOptionsFactory
class Meta:
abstract = True
session_manager: SessionManager = injectable
@classmethod
def methods(cls):
for method in ALL_RESOURCE_METHODS:
if (method in cls.Meta.exclude_methods
or method not in cls.Meta.include_methods):
continue
yield method
@route
def list(self, instances):
"""
List model instances.
:param instances: The list of model instances.
:return: The list of model instances.
"""
return instances
@route
def create(self, instance, errors):
"""
Create an instance of a model.
:param instance: The created model instance.
:param errors: Any errors.
:return: The created model instance, or a dictionary of errors.
"""
if errors:
return self.errors(errors)
return self.created(instance)
@route
def get(self, instance):
"""
Get an instance of a model.
:param instance: The model instance.
:return: The model instance.
"""
return instance
@route
def patch(self, instance, errors):
"""
Partially update a model instance.
:param instance: The model instance.
:param errors: Any errors.
:return: The updated model instance, or a dictionary of errors.
"""
if errors:
return self.errors(errors)
return self.updated(instance)
@route
def put(self, instance, errors):
"""
Update a model instance.
:param instance: The model instance.
:param errors: Any errors.
:return: The updated model instance, or a dictionary of errors.
"""
if errors:
return self.errors(errors)
return self.updated(instance)
@route
def delete(self, instance):
"""
Delete a model instance.
:param instance: The model instance.
:return: HTTPStatus.NO_CONTENT
"""
return self.deleted(instance)
def created(self, instance, commit=True):
"""
Convenience method for saving a model (automatically commits it to
the database and returns the object with an HTTP 201 status code)
"""
if commit:
self.session_manager.save(instance, commit=True)
return instance, HTTPStatus.CREATED
def deleted(self, instance):
"""
Convenience method for deleting a model (automatically commits the
delete to the database and returns with an HTTP 204 status code)
"""
self.session_manager.delete(instance, commit=True)
return '', HTTPStatus.NO_CONTENT
def updated(self, instance):
"""
Convenience method for updating a model (automatically commits it to
the database and returns the object with with an HTTP 200 status code)
"""
self.session_manager.save(instance, commit=True)
return instance
def dispatch_request(self, method_name, *view_args, **view_kwargs):
resp = super().dispatch_request(method_name, *view_args, **view_kwargs)
rv, code, headers = unpack(resp)
if isinstance(rv, Response):
return self.make_response(rv, code, headers)
if isinstance(rv, list) and rv and isinstance(rv[0], self.Meta.model):
rv = self.Meta.serializer_many.dump(rv)
elif isinstance(rv, self.Meta.model):
rv = self.Meta.serializer.dump(rv)
return self.make_response(rv, code, headers)
def make_response(self, data, code=200, headers=None): # skipcq: PYL-W0221
headers = headers or {}
if isinstance(data, Response):
return make_response(data, code, headers)
# FIXME need to support ETags
# see https://github.com/Nobatek/flask-rest-api/blob/master/flask_rest_api/response.py
accept = request.headers.get('Accept', 'application/json')
try:
dump_fn = current_app.config.ACCEPT_HANDLERS[accept]
except KeyError as e:
# see if we can use JSON when there is no handler for the requested Accept header
if '*/*' not in accept:
raise e
dump_fn = current_app.config.ACCEPT_HANDLERS['application/json']
return make_response(dump_fn(data), code, headers)
def get_decorators(self, method_name):
decorators = list(super().get_decorators(method_name)).copy()
if method_name not in ALL_RESOURCE_METHODS:
return decorators
if isinstance(self.Meta.method_decorators, dict):
decorators += list(self.Meta.method_decorators.get(method_name, []))
elif isinstance(self.Meta.method_decorators, (list, tuple)):
decorators += list(self.Meta.method_decorators)
if (method_name in self.Meta.exclude_decorators
or method_name not in self.Meta.include_decorators):
return decorators
if method_name == LIST:
decorators.append(partial(list_loader, model=self.Meta.model))
elif method_name in RESOURCE_MEMBER_METHODS:
param_name = get_param_tuples(self.Meta.member_param)[0][1]
kw_name = 'instance' # needed by the patch/put loaders
# for get/delete, allow subclasses to rename view fn args
# (the patch/put loaders call view functions with positional args,
# so no need to inspect function signatures for them)
if method_name in {DELETE, GET}:
sig = inspect.signature(getattr(self, method_name))
kw_name = list(sig.parameters.keys())[0]
decorators.append(partial(
param_converter, **{param_name: {kw_name: self.Meta.model}}))
if method_name == CREATE:
decorators.append(partial(post_loader,
serializer=self.Meta.serializer_create))
elif method_name == PATCH:
decorators.append(partial(patch_loader,
serializer=self.Meta.serializer))
elif method_name == PUT:
decorators.append(partial(put_loader,
serializer=self.Meta.serializer))
return decorators
__all__ = [
'ModelResource',
'ModelResourceMetaclass',
'ModelResourceMetaOptionsFactory',
]
| 46,493
|
https://github.com/LaxarJS/grunt-init-laxar-application/blob/master/root/demo.includes/widgets/example/my-editor-widget/spec/spec_runner.js
|
Github Open Source
|
Open Source
|
MIT
| null |
grunt-init-laxar-application
|
LaxarJS
|
JavaScript
|
Code
| 56
| 139
|
/**
* Copyright {%= grunt.template.today('yyyy') %} {%= author_name %}{% if( licenses.length ) { %}
* Released under the {%= licenses.join(', ') %} license{%= licenses.length === 1 ? '' : 's' %}.{% } %}
*/
( function( global ) {
'use strict';
global.laxarSpec = {
title: 'MyEditorWidget Specification',
tests: [
'my-editor-widget.spec'
]
};
} )( this );
| 5,001
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.